@@ -23,7 +23,13 @@ test_expect_success setup '
23
23
test_tick &&
24
24
git commit -a -m $i || return 1
25
25
done &&
26
+ git branch changes &&
26
27
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 &&
27
33
git checkout -b side initial &&
28
34
echo local change >file-2-expect
29
35
'
@@ -191,4 +197,37 @@ test_expect_success 'am --abort leaves index stat info alone' '
191
197
git diff-files --exit-code --quiet
192
198
'
193
199
200
+ test_expect_failure ' 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
+
194
233
test_done
0 commit comments