From: Michael J Gruber Date: Thu, 26 Feb 2009 09:52:53 +0000 (+0100) Subject: git-am: Keep index in case of abort with dirty index X-Git-Tag: v1.6.2~18 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c767184d8f99404d456b32a2c6c5c41d6db7a847;p=git.git git-am: Keep index in case of abort with dirty index git am --abort resets the index unconditionally. But in case a previous git am exited due to a dirty index it is preferable to keep that index. Make it so. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- diff --git a/git-am.sh b/git-am.sh index 8bcb20602..351b4f86f 100755 --- a/git-am.sh +++ b/git-am.sh @@ -230,11 +230,14 @@ then ;; ,t) git rerere clear - git read-tree --reset -u HEAD ORIG_HEAD - git reset ORIG_HEAD + test -f "$dotest/dirtyindex" || { + git read-tree --reset -u HEAD ORIG_HEAD + git reset ORIG_HEAD + } rm -fr "$dotest" exit ;; esac + rm -f "$dotest/dirtyindex" else # Make sure we are not given --skip, --resolved, nor --abort test "$skip$resolved$abort" = "" || @@ -287,7 +290,11 @@ fi case "$resolved" in '') files=$(git diff-index --cached --name-only HEAD --) || exit - test "$files" && die "Dirty index: cannot apply patches (dirty: $files)" + if test "$files" + then + : >"$dotest/dirtyindex" + die "Dirty index: cannot apply patches (dirty: $files)" + fi esac if test "$(cat "$dotest/utf8")" = t