summaryrefslogtreecommitdiff
path: root/git-am.sh
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2009-02-26 09:52:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-02-27 07:06:27 (GMT)
commitc767184d8f99404d456b32a2c6c5c41d6db7a847 (patch)
tree7799df4bddbc19b84121fb512a21d79d8e0bbe6e /git-am.sh
parent2591838beece01f98773109a7c6932525be2d144 (diff)
downloadgit-c767184d8f99404d456b32a2c6c5c41d6db7a847.zip
git-c767184d8f99404d456b32a2c6c5c41d6db7a847.tar.gz
git-c767184d8f99404d456b32a2c6c5c41d6db7a847.tar.bz2
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 <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-am.sh')
-rwxr-xr-xgit-am.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/git-am.sh b/git-am.sh
index 8bcb206..351b4f8 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