@matheusbsbs / matheus-bagliano / commits / c767184d8f
Fork 0

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>

Michael J Gruber committed Feb 26, 2009 at 10:52 UTC c767184d8f99404d456b32a2c6c5c41d6db7a847
1 file changed +10 -3
git-am.sh
+10 -3
@@ -230,11 +230,14 @@ then
230 ;;
231 ,t)
232 git rerere clear
233 - git read-tree --reset -u HEAD ORIG_HEAD
234 - git reset ORIG_HEAD
233 + test -f "$dotest/dirtyindex" || {
234 + git read-tree --reset -u HEAD ORIG_HEAD
235 + git reset ORIG_HEAD
236 + }
237 rm -fr "$dotest"
238 exit ;;
239 esac
240 + rm -f "$dotest/dirtyindex"
241 else
242 # Make sure we are not given --skip, --resolved, nor --abort
243 test "$skip$resolved$abort" = "" ||
@@ -287,7 +290,11 @@ fi
290 case "$resolved" in
291 '')
292 files=$(git diff-index --cached --name-only HEAD --) || exit
290 - test "$files" && die "Dirty index: cannot apply patches (dirty: $files)"
293 + if test "$files"
294 + then
295 + : >"$dotest/dirtyindex"
296 + die "Dirty index: cannot apply patches (dirty: $files)"
297 + fi
298 esac
299
300 if test "$(cat "$dotest/utf8")" = t