X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-am.sh;h=f4db17d93424c18c1db53e9bf84cdeee8219fa10;hb=8a59702ad888c8c399b096759c1c678ffeca5b03;hp=e7f008c7baae2ff484e16882e199b6b9d75195aa;hpb=33a0292e612915320e56f392b3372589f602a9e6;p=git.git diff --git a/git-am.sh b/git-am.sh index e7f008c7b..f4db17d93 100755 --- a/git-am.sh +++ b/git-am.sh @@ -5,7 +5,7 @@ SUBDIRECTORY_OK=Yes OPTIONS_KEEPDASHDASH= OPTIONS_SPEC="\ -git am [options] [|...] +git am [options] [(|)...] git am [options] (--resolved | --skip | --abort) -- i,interactive run interactively @@ -68,9 +68,31 @@ sq () { stop_here () { echo "$1" >"$dotest/next" + git rev-parse --verify -q HEAD >"$dotest/abort-safety" exit 1 } +safe_to_abort () { + if test -f "$dotest/dirtyindex" + then + return 1 + fi + + if ! test -s "$dotest/abort-safety" + then + return 0 + fi + + abort_safety=$(cat "$dotest/abort-safety") + if test "z$(git rev-parse --verify -q HEAD)" = "z$abort_safety" + then + return 0 + fi + echo >&2 "You seem to have moved HEAD since the last 'am' failure." + echo >&2 "Not rewinding to ORIG_HEAD" + return 1 +} + stop_here_user_resolve () { if [ -n "$resolvemsg" ]; then printf '%s\n' "$resolvemsg" @@ -137,7 +159,7 @@ It does not apply to blobs recorded in its index." export GITHEAD_$his_tree if test -n "$GIT_QUIET" then - export GIT_MERGE_VERBOSITY=0 + GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY fi git-merge-recursive $orig_tree -- HEAD $his_tree || { git rerere $allow_rerere_autoupdate @@ -419,10 +441,11 @@ then exec git rebase --abort fi git rerere clear - test -f "$dotest/dirtyindex" || { + if safe_to_abort + then git read-tree --reset -u HEAD ORIG_HEAD git reset ORIG_HEAD - } + fi rm -fr "$dotest" exit ;; esac @@ -554,13 +577,6 @@ then resume= fi -if test "$this" -gt "$last" -then - say Nothing to do. - rm -fr "$dotest" - exit -fi - while test "$this" -le "$last" do msgnum=`printf "%0${prec}d" $this`