Merge branch 'cc/test-ref-store-typofix'
[gitweb.git] / git-legacy-rebase.sh
index 75a08b2683e76e6832475bc91e4d4f38b3d3bc3c..3bb0682db5897f514d267946979fa2b9cfa43f20 100755 (executable)
@@ -26,6 +26,7 @@ f,force-rebase!    cherry-pick all commits, even if unchanged
 m,merge!           use merging strategies to rebase
 i,interactive!     let the user edit the list of commits to rebase
 x,exec=!           add exec lines after each commit of the editable list
+y=!                same as --reschedule-failed-exec -x
 k,keep-empty      preserve empty commits during rebase
 allow-empty-message allow rebasing commits with empty messages
 stat!              display a diffstat of what changed upstream
@@ -48,6 +49,7 @@ skip!              skip current patch and continue
 edit-todo!         edit the todo list during an interactive rebase
 quit!              abort but keep HEAD where it is
 show-current-patch! show the patch file being applied or merged
+reschedule-failed-exec automatically reschedule failed exec commands
 "
 . git-sh-setup
 set_reflog_action rebase
@@ -92,11 +94,14 @@ autosquash=
 keep_empty=
 allow_empty_message=--allow-empty-message
 signoff=
+reschedule_failed_exec=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
 case "$(git config --bool commit.gpgsign)" in
 true)  gpg_sign_opt=-S ;;
 *)     gpg_sign_opt= ;;
 esac
+test "$(git config --bool rebase.reschedulefailedexec)" = "true" &&
+reschedule_failed_exec=--reschedule-failed-exec
 . git-rebase--common
 
 read_basic_state () {
@@ -126,6 +131,8 @@ read_basic_state () {
                signoff="$(cat "$state_dir"/signoff)"
                force_rebase=t
        }
+       test -f "$state_dir"/reschedule-failed-exec &&
+               reschedule_failed_exec=t
 }
 
 finish_rebase () {
@@ -163,7 +170,8 @@ run_interactive () {
                "$allow_empty_message" "$autosquash" "$verbose" \
                "$force_rebase" "$onto_name" "$head_name" "$strategy" \
                "$strategy_opts" "$cmd" "$switch_to" \
-               "$allow_rerere_autoupdate" "$gpg_sign_opt" "$signoff"
+               "$allow_rerere_autoupdate" "$gpg_sign_opt" "$signoff" \
+               "$reschedule_failed_exec"
 }
 
 run_specific_rebase () {
@@ -255,6 +263,11 @@ do
                cmd="${cmd}exec ${1#--exec=}${LF}"
                test -z "$interactive_rebase" && interactive_rebase=implied
                ;;
+       -y*)
+               reschedule_failed_exec=--reschedule-failed-exec
+               cmd="${cmd}exec ${1#-y}${LF}"
+               test -z "$interactive_rebase" && interactive_rebase=implied
+               ;;
        --interactive)
                interactive_rebase=explicit
                ;;
@@ -337,6 +350,11 @@ do
                fix|strip)
                        force_rebase=t
                        ;;
+               warn|nowarn|error|error-all)
+                       ;; # okay, known whitespace option
+               *)
+                       die "fatal: Invalid whitespace option: '${1#*=}'"
+                       ;;
                esac
                ;;
        --ignore-whitespace)
@@ -352,6 +370,9 @@ do
                git_am_opt="$git_am_opt $1"
                force_rebase=t
                ;;
+       -C*[!0-9]*)
+               die "fatal: switch \`C' expects a numerical value"
+               ;;
        -C*)
                git_am_opt="$git_am_opt $1"
                ;;
@@ -370,6 +391,12 @@ do
        --gpg-sign=*)
                gpg_sign_opt="-S${1#--gpg-sign=}"
                ;;
+       --reschedule-failed-exec)
+               reschedule_failed_exec=--reschedule-failed-exec
+               ;;
+       --no-reschedule-failed-exec)
+               reschedule_failed_exec=
+               ;;
        --)
                shift
                break
@@ -526,6 +553,9 @@ then
        #       git-rebase.txt caveats with "unless you know what you are doing"
        test -n "$rebase_merges" &&
                die "$(gettext "error: cannot combine '--preserve-merges' with '--rebase-merges'")"
+
+       test -n "$reschedule_failed_exec" &&
+               die "$(gettext "error: cannot combine '--preserve-merges' with '--reschedule-failed-exec'")"
 fi
 
 if test -n "$rebase_merges"
@@ -710,10 +740,16 @@ if test -n "$diffstat"
 then
        if test -n "$verbose"
        then
-               echo "$(eval_gettext "Changes from \$mb to \$onto:")"
+               if test -z "$mb"
+               then
+                       echo "$(eval_gettext "Changes to \$onto:")"
+               else
+                       echo "$(eval_gettext "Changes from \$mb to \$onto:")"
+               fi
        fi
+       mb_tree="${mb:-$(git hash-object -t tree /dev/null)}"
        # We want color (if set), but no pager
-       GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
+       GIT_PAGER='' git diff --stat --summary "$mb_tree" "$onto"
 fi
 
 test -n "$interactive_rebase" && run_specific_rebase