diff options
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-x | git-rebase.sh | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/git-rebase.sh b/git-rebase.sh index 3eac5a48b6..aa1bcaf07f 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -64,6 +64,9 @@ type= state_dir= # One of {'', continue, skip, abort}, as parsed from command line action= +preserve_merges= +autosquash= +test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t read_state () { if test "$type" = merge @@ -176,27 +179,12 @@ finish_rb_merge () { say All done. } -is_interactive () { - while test $# != 0 - do - case "$1" in - -i|--interactive) - interactive_rebase=explicit - break - ;; - -p|--preserve-merges) - interactive_rebase=implied - ;; - esac - shift - done - +run_interactive_rebase () { if [ "$interactive_rebase" = implied ]; then GIT_EDITOR=: export GIT_EDITOR fi - - test -n "$interactive_rebase" || test -f "$merge_dir"/interactive + . git-rebase--interactive "$@" } run_pre_rebase_hook () { @@ -211,8 +199,6 @@ run_pre_rebase_hook () { test -f "$apply_dir"/applying && die 'It looks like git-am is in progress. Cannot rebase.' -is_interactive "$@" && exec git-rebase--interactive "$@" - if test -d "$apply_dir" then type=am @@ -249,6 +235,19 @@ do onto="$2" shift ;; + -i|--interactive) + interactive_rebase=explicit + ;; + -p|--preserve-merges) + preserve_merges=t + test -z "$interactive_rebase" && interactive_rebase=implied + ;; + --autosquash) + autosquash=t + ;; + --no-autosquash) + autosquash= + ;; -M|-m|--m|--me|--mer|--merg|--merge) do_merge=t ;; @@ -339,7 +338,11 @@ do done test $# -gt 2 && usage -test -n "$action" && test -z "$in_progress" && die "No rebase in progress?" +if test -n "$action" +then + test -z "$in_progress" && die "No rebase in progress?" + test "$type" = interactive && run_interactive_rebase +fi case "$action" in continue) @@ -415,6 +418,21 @@ fi test $# -eq 0 && test -z "$rebase_root" && usage +if test -n "$interactive_rebase" +then + type=interactive + state_dir="$merge_dir" +elif test -n "$do_merge" +then + type=merge + state_dir="$merge_dir" +else + type=am + state_dir="$apply_dir" +fi + +test "$type" = interactive && run_interactive_rebase "$@" + require_clean_work_tree "rebase" "Please commit or stash them." if test -z "$rebase_root" |