Skip to content

Commit

Permalink
git-am: Keep index in case of abort with dirty index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Feb 27, 2009
1 parent 2591838 commit c767184
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" = "" ||
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c767184

Please sign in to comment.