Code

Porcelain scripts: Rewrite cryptic "needs update" error message
[git.git] / git-rebase--interactive.sh
index 4d14b077d22ac030956fa686b637ac86763f05c0..4d8a2a0e4e2b6f5f70e75269dde082d13838b5f2 100755 (executable)
@@ -114,9 +114,9 @@ AUTOSQUASH=
 test "$(git config --bool rebase.autosquash)" = "true" && AUTOSQUASH=t
 NEVER_FF=
 
-GIT_CHERRY_PICK_HELP="  After resolving the conflicts,
-mark the corrected paths with 'git add <paths>', and
-run 'git rebase --continue'"
+GIT_CHERRY_PICK_HELP="\
+hint: after resolving the conflicts, mark the corrected paths
+hint: with 'git add <paths>' and run 'git rebase --continue'"
 export GIT_CHERRY_PICK_HELP
 
 warn () {
@@ -153,14 +153,6 @@ run_pre_rebase_hook () {
        fi
 }
 
-require_clean_work_tree () {
-       # test if working tree is dirty
-       git rev-parse --verify HEAD > /dev/null &&
-       git update-index --ignore-submodules --refresh &&
-       git diff-files --quiet --ignore-submodules &&
-       git diff-index --cached --quiet HEAD --ignore-submodules -- ||
-       die "Working tree is dirty"
-}
 
 ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
 
@@ -557,7 +549,7 @@ do_next () {
                        exit "$status"
                fi
                # Run in subshell because require_clean_work_tree can die.
-               if ! (require_clean_work_tree)
+               if ! (require_clean_work_tree "rebase")
                then
                        warn "Commit or stash your changes, and then run"
                        warn
@@ -626,7 +618,7 @@ skip_unnecessary_picks () {
                case "$fd,$command" in
                3,pick|3,p)
                        # pick a commit whose parent is current $ONTO -> skip
-                       sha1=$(printf '%s' "$rest" | cut -d ' ' -f 1)
+                       sha1=${rest%% *}
                        case "$(git rev-parse --verify --quiet "$sha1"^)" in
                        "$ONTO"*)
                                ONTO=$sha1
@@ -768,7 +760,7 @@ first and then run 'git rebase --continue' again."
 
                record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
 
-               require_clean_work_tree
+               require_clean_work_tree "rebase"
                do_rest
                ;;
        --abort)
@@ -866,7 +858,7 @@ first and then run 'git rebase --continue' again."
 
                comment_for_reflog start
 
-               require_clean_work_tree
+               require_clean_work_tree "rebase" "Please commit or stash them."
 
                if test ! -z "$1"
                then