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

Commit 76689ab

Browse files
committed
Merge branch 'rr/am-quit-empty-then-abort-fix'
Recent "rebase --autostash" update made it impossible to recover with "git am --abort" from a repository where "git am" without mbox was run by mistake and then was killed with "^C". * rr/am-quit-empty-then-abort-fix: t/am: use test_path_is_missing() where appropriate am: handle stray $dotest directory
2 parents 001d116 + 61e0eb9 commit 76689ab

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
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: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test_expect_success 'am applies patch correctly' '
147147
git checkout first &&
148148
test_tick &&
149149
git am <patch1 &&
150-
! test -d .git/rebase-apply &&
150+
test_path_is_missing .git/rebase-apply &&
151151
git diff --exit-code second &&
152152
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
153153
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
@@ -158,7 +158,7 @@ test_expect_success 'am applies patch e-mail not in a mbox' '
158158
git reset --hard &&
159159
git checkout first &&
160160
git am patch1.eml &&
161-
! test -d .git/rebase-apply &&
161+
test_path_is_missing .git/rebase-apply &&
162162
git diff --exit-code second &&
163163
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
164164
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
@@ -169,7 +169,7 @@ test_expect_success 'am applies patch e-mail not in a mbox with CRLF' '
169169
git reset --hard &&
170170
git checkout first &&
171171
git am patch1-crlf.eml &&
172-
! test -d .git/rebase-apply &&
172+
test_path_is_missing .git/rebase-apply &&
173173
git diff --exit-code second &&
174174
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
175175
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
@@ -180,7 +180,7 @@ test_expect_success 'am applies patch e-mail with preceding whitespace' '
180180
git reset --hard &&
181181
git checkout first &&
182182
git am patch1-ws.eml &&
183-
! test -d .git/rebase-apply &&
183+
test_path_is_missing .git/rebase-apply &&
184184
git diff --exit-code second &&
185185
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
186186
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
@@ -206,7 +206,7 @@ test_expect_success 'am changes committer and keeps author' '
206206
git reset --hard &&
207207
git checkout first &&
208208
git am patch2 &&
209-
! test -d .git/rebase-apply &&
209+
test_path_is_missing .git/rebase-apply &&
210210
test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
211211
git diff --exit-code master..HEAD &&
212212
git diff --exit-code master^..HEAD^ &&
@@ -258,7 +258,7 @@ test_expect_success 'am --keep really keeps the subject' '
258258
git reset --hard &&
259259
git checkout HEAD^ &&
260260
git am --keep patch4 &&
261-
! test -d .git/rebase-apply &&
261+
test_path_is_missing .git/rebase-apply &&
262262
git cat-file commit HEAD >actual &&
263263
grep "Re: Re: Re: \[PATCH 1/5 v2\] \[foo\] third" actual
264264
'
@@ -268,7 +268,7 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' '
268268
git reset --hard &&
269269
git checkout HEAD^ &&
270270
git am --keep-non-patch patch4 &&
271-
! test -d .git/rebase-apply &&
271+
test_path_is_missing .git/rebase-apply &&
272272
git cat-file commit HEAD >actual &&
273273
grep "^\[foo\] third" actual
274274
'
@@ -283,7 +283,7 @@ test_expect_success 'am -3 falls back to 3-way merge' '
283283
test_tick &&
284284
git commit -m "copied stuff" &&
285285
git am -3 lorem-move.patch &&
286-
! test -d .git/rebase-apply &&
286+
test_path_is_missing .git/rebase-apply &&
287287
git diff --exit-code lorem
288288
'
289289

@@ -297,7 +297,7 @@ test_expect_success 'am -3 -p0 can read --no-prefix patch' '
297297
test_tick &&
298298
git commit -m "copied stuff" &&
299299
git am -3 -p0 lorem-zero.patch &&
300-
! test -d .git/rebase-apply &&
300+
test_path_is_missing .git/rebase-apply &&
301301
git diff --exit-code lorem
302302
'
303303

@@ -307,7 +307,7 @@ test_expect_success 'am can rename a file' '
307307
git reset --hard &&
308308
git checkout lorem^0 &&
309309
git am rename.patch &&
310-
! test -d .git/rebase-apply &&
310+
test_path_is_missing .git/rebase-apply &&
311311
git update-index --refresh &&
312312
git diff --exit-code rename
313313
'
@@ -318,7 +318,7 @@ test_expect_success 'am -3 can rename a file' '
318318
git reset --hard &&
319319
git checkout lorem^0 &&
320320
git am -3 rename.patch &&
321-
! test -d .git/rebase-apply &&
321+
test_path_is_missing .git/rebase-apply &&
322322
git update-index --refresh &&
323323
git diff --exit-code rename
324324
'
@@ -329,7 +329,7 @@ test_expect_success 'am -3 can rename a file after falling back to 3-way merge'
329329
git reset --hard &&
330330
git checkout lorem^0 &&
331331
git am -3 rename-add.patch &&
332-
! test -d .git/rebase-apply &&
332+
test_path_is_missing .git/rebase-apply &&
333333
git update-index --refresh &&
334334
git diff --exit-code rename
335335
'
@@ -358,11 +358,17 @@ test_expect_success 'am pauses on conflict' '
358358
test_expect_success 'am --skip works' '
359359
echo goodbye >expected &&
360360
git am --skip &&
361-
! test -d .git/rebase-apply &&
361+
test_path_is_missing .git/rebase-apply &&
362362
git diff --exit-code lorem2^^ -- file &&
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 &&
@@ -373,7 +379,7 @@ test_expect_success 'am --resolved works' '
373379
echo resolved >>file &&
374380
git add file &&
375381
git am --resolved &&
376-
! test -d .git/rebase-apply &&
382+
test_path_is_missing .git/rebase-apply &&
377383
test_cmp expected another
378384
'
379385

@@ -382,7 +388,7 @@ test_expect_success 'am takes patches from a Pine mailbox' '
382388
git reset --hard &&
383389
git checkout first &&
384390
cat pine patch1 | git am &&
385-
! test -d .git/rebase-apply &&
391+
test_path_is_missing .git/rebase-apply &&
386392
git diff --exit-code master^..HEAD
387393
'
388394

@@ -391,7 +397,7 @@ test_expect_success 'am fails on mail without patch' '
391397
git reset --hard &&
392398
test_must_fail git am <failmail &&
393399
git am --abort &&
394-
! test -d .git/rebase-apply
400+
test_path_is_missing .git/rebase-apply
395401
'
396402

397403
test_expect_success 'am fails on empty patch' '
@@ -400,7 +406,7 @@ test_expect_success 'am fails on empty patch' '
400406
echo "---" >>failmail &&
401407
test_must_fail git am <failmail &&
402408
git am --skip &&
403-
! test -d .git/rebase-apply
409+
test_path_is_missing .git/rebase-apply
404410
'
405411

406412
test_expect_success 'am works from stdin in subdirectory' '

0 commit comments

Comments
 (0)