@@ -23,7 +23,13 @@ test_expect_success setup '
2323 test_tick &&
2424 git commit -a -m $i || return 1
2525 done &&
26+ git branch changes &&
2627 git format-patch --no-numbered initial &&
28+ git checkout -b conflicting initial &&
29+ echo different >>file-1 &&
30+ echo whatever >new-file &&
31+ git add file-1 new-file &&
32+ git commit -m different &&
2733 git checkout -b side initial &&
2834 echo local change >file-2-expect
2935'
@@ -191,4 +197,37 @@ test_expect_success 'am --abort leaves index stat info alone' '
191197 git diff-files --exit-code --quiet
192198'
193199
200+ test_expect_success ' git am --abort return failed exit status when it fails' '
201+ test_when_finished "rm -rf file-2/ && git reset --hard && git am --abort" &&
202+ git checkout changes &&
203+ git format-patch -1 --stdout conflicting >changes.mbox &&
204+ test_must_fail git am --3way changes.mbox &&
205+
206+ git rm file-2 &&
207+ mkdir file-2 &&
208+ echo precious >file-2/somefile &&
209+ test_must_fail git am --abort &&
210+ test_path_is_dir file-2/
211+ '
212+
213+ test_expect_success ' git am --abort cleans relevant files' '
214+ git checkout changes &&
215+ git format-patch -1 --stdout conflicting >changes.mbox &&
216+ test_must_fail git am --3way changes.mbox &&
217+
218+ test_path_is_file new-file &&
219+ echo further changes >>file-1 &&
220+ echo change other file >>file-2 &&
221+
222+ # Abort, and expect the files touched by am to be reverted
223+ git am --abort &&
224+
225+ test_path_is_missing new-file &&
226+
227+ # Files not involved in am operation are left modified
228+ git diff --name-only changes >actual &&
229+ test_write_lines file-2 >expect &&
230+ test_cmp expect actual
231+ '
232+
194233test_done
0 commit comments