diff options
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-x | git-rebase.sh | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/git-rebase.sh b/git-rebase.sh index 8a3efa2983..47ca3b990b 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -5,6 +5,7 @@ SUBDIRECTORY_OK=Yes OPTIONS_KEEPDASHDASH= +OPTIONS_STUCKLONG=t OPTIONS_SPEC="\ git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>] git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>] @@ -36,6 +37,7 @@ ignore-date! passed to 'git am' whitespace=! passed to 'git apply' ignore-whitespace! passed to 'git apply' C=! passed to 'git apply' +S,gpg-sign? GPG-sign commits Actions: continue! continue abort! abort and check out the original branch @@ -84,6 +86,7 @@ preserve_merges= autosquash= keep_empty= test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t +gpg_sign_opt= read_basic_state () { test -f "$state_dir/head-name" && @@ -106,6 +109,8 @@ read_basic_state () { strategy_opts="$(cat "$state_dir"/strategy_opts)" test -f "$state_dir"/allow_rerere_autoupdate && allow_rerere_autoupdate="$(cat "$state_dir"/allow_rerere_autoupdate)" + test -f "$state_dir"/gpg_sign_opt && + gpg_sign_opt="$(cat "$state_dir"/gpg_sign_opt)" } write_basic_state () { @@ -119,6 +124,7 @@ write_basic_state () { "$state_dir"/strategy_opts test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \ "$state_dir"/allow_rerere_autoupdate + test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt } output () { @@ -149,7 +155,7 @@ move_to_original_branch () { esac } -finish_rebase () { +apply_autostash () { if test -f "$state_dir/autostash" then stash_sha1=$(cat "$state_dir/autostash") @@ -165,30 +171,30 @@ You can run "git stash pop" or "git stash drop" at any time. ' fi fi +} + +finish_rebase () { + apply_autostash && git gc --auto && rm -rf "$state_dir" } -run_specific_rebase_internal () { +run_specific_rebase () { if [ "$interactive_rebase" = implied ]; then GIT_EDITOR=: export GIT_EDITOR autosquash= fi - # On FreeBSD, the shell's "return" returns from the current - # function, not from the current file inclusion. - # run_specific_rebase_internal has the file inclusion as a - # last statement, so POSIX and FreeBSD's return will do the - # same thing. . git-rebase--$type -} - -run_specific_rebase () { - run_specific_rebase_internal ret=$? if test $ret -eq 0 then finish_rebase + elif test $ret -eq 2 # special exit status for rebase -i + then + apply_autostash && + rm -rf "$state_dir" && + die "Nothing to do" fi exit $ret } @@ -236,23 +242,19 @@ do test $total_argc -eq 2 || usage action=${1##--} ;; - --onto) - test 2 -le "$#" || usage - onto="$2" - shift + --onto=*) + onto="${1#--onto=}" ;; - -x) - test 2 -le "$#" || usage - cmd="${cmd}exec $2${LF}" - shift + --exec=*) + cmd="${cmd}exec ${1#--exec=}${LF}" ;; - -i) + --interactive) interactive_rebase=explicit ;; - -k) + --keep-empty) keep_empty=yes ;; - -p) + --preserve-merges) preserve_merges=t test -z "$interactive_rebase" && interactive_rebase=implied ;; @@ -268,21 +270,19 @@ do --no-fork-point) fork_point= ;; - -M|-m) + --merge) do_merge=t ;; - -X) - shift - strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$1")" + --strategy-option=*) + strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--${1#--strategy-option=}")" do_merge=t test -z "$strategy" && strategy=recursive ;; - -s) - shift - strategy="$1" + --strategy=*) + strategy="${1#--strategy=}" do_merge=t ;; - -n) + --no-stat) diffstat= ;; --stat) @@ -291,21 +291,20 @@ do --autostash) autostash=true ;; - -v) + --verbose) verbose=t diffstat=t GIT_QUIET= ;; - -q) + --quiet) GIT_QUIET=t git_am_opt="$git_am_opt -q" verbose= diffstat= ;; - --whitespace) - shift - git_am_opt="$git_am_opt --whitespace=$1" - case "$1" in + --whitespace=*) + git_am_opt="$git_am_opt --whitespace=${1#--whitespace=}" + case "${1#--whitespace=}" in fix|strip) force_rebase=t ;; @@ -318,19 +317,24 @@ do git_am_opt="$git_am_opt $1" force_rebase=t ;; - -C) - shift - git_am_opt="$git_am_opt -C$1" + -C*) + git_am_opt="$git_am_opt $1" ;; --root) rebase_root=t ;; - -f|--no-ff) + --force-rebase|--no-ff) force_rebase=t ;; --rerere-autoupdate|--no-rerere-autoupdate) allow_rerere_autoupdate="$1" ;; + --gpg-sign) + gpg_sign_opt=-S + ;; + --gpg-sign=*) + gpg_sign_opt="-S${1#--gpg-sign=}" + ;; --) shift break @@ -449,6 +453,10 @@ then test "$fork_point" = auto && fork_point=t ;; *) upstream_name="$1" + if test "$upstream_name" = "-" + then + upstream_name="@{-1}" + fi shift ;; esac |