From: Junio C Hamano Date: Tue, 28 Dec 2010 21:43:10 +0000 (-0800) Subject: Merge branch 'jc/maint-rebase-rewrite-last-skip' into maint X-Git-Tag: v1.7.4-rc0~1^2~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/58c58c8624d77ff4087ad93e515402db218684f6?ds=inline;hp=-c Merge branch 'jc/maint-rebase-rewrite-last-skip' into maint * jc/maint-rebase-rewrite-last-skip: rebase --skip: correctly wrap-up when skipping the last patch --- 58c58c8624d77ff4087ad93e515402db218684f6 diff --combined git-am.sh index e5671f61c6,69474e5da2..f4db17d934 --- a/git-am.sh +++ b/git-am.sh @@@ -68,31 -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" @@@ -441,11 -419,10 +441,11 @@@ the 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 @@@ -577,13 -554,6 +577,6 @@@ the 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`