Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit b141f3c

Browse files
artagnongitster
authored andcommitted
am: handle stray $dotest directory
The following bug has been observed: $ git am # no input file ^C $ git am --abort Resolve operation not in progress, we are not resuming. This happens because the following test fails: test -d "$dotest" && test -f "$dotest/last" && test -f "$dotest/next" and the codepath for an "am in-progress" is not executed. It falls back to the codepath that treats this as a "fresh execution". Before rr/rebase-autostash, this condition was test -d "$dotest" It would incorrectly execute the "normal" am --abort codepath: git read-tree --reset -u HEAD ORIG_HEAD git reset ORIG_HEAD by incorrectly assuming that an am is "in progress" (i.e. ORIG_HEAD etc. was written during the previous execution). Notice that $ git am ^C executes nothing of significance, is equivalent to $ mkdir .git/rebase-apply Therefore, the correct solution is to treat .git/rebase-apply as a "stray directory" and remove it on --abort in the fresh-execution codepath. Also ensure that we're not called with --rebasing from git-rebase--am.sh; in that case, it is the responsibility of the caller to handle and stray directories. While at it, tell the user to run "git am --abort" to get rid of the stray $dotest directory, if she attempts anything else. Reported-by: Junio C Hamano <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5879477 commit b141f3c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

git-am.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,23 @@ then
506506
esac
507507
rm -f "$dotest/dirtyindex"
508508
else
509+
# Possible stray $dotest directory in the independent-run
510+
# case; in the --rebasing case, it is upto the caller
511+
# (git-rebase--am) to take care of stray directories.
512+
if test -d "$dotest" && test -z "$rebasing"
513+
then
514+
case "$skip,$resolved,$abort" in
515+
,,t)
516+
rm -fr "$dotest"
517+
exit 0
518+
;;
519+
*)
520+
die "$(eval_gettext "Stray \$dotest directory found.
521+
Use \"git am --abort\" to remove it.")"
522+
;;
523+
esac
524+
fi
525+
509526
# Make sure we are not given --skip, --resolved, nor --abort
510527
test "$skip$resolved$abort" = "" ||
511528
die "$(gettext "Resolve operation not in progress, we are not resuming.")"

t/t4150-am.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ test_expect_success 'am --skip works' '
363363
test_cmp expected another
364364
'
365365

366+
test_expect_success 'am --abort removes a stray directory' '
367+
mkdir .git/rebase-apply &&
368+
git am --abort &&
369+
test_path_is_missing .git/rebase-apply
370+
'
371+
366372
test_expect_success 'am --resolved works' '
367373
echo goodbye >expected &&
368374
rm -fr .git/rebase-apply &&

0 commit comments

Comments
 (0)