t4151: add a few am --abort tests
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Sep 10, 2021 at 10:31 UTC
42b5e09d1e555689168941eb639be644d004cb9d
1 file changed
+39
t/t4151-am-abort.sh
+39
@@ -23,7 +23,13 @@ test_expect_success setup '
23
test_tick &&
24
git commit -a -m $i || return 1
25
done &&
26
+ git branch changes &&
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 &&
33
git checkout -b side initial &&
34
echo local change >file-2-expect
35
'
@@ -191,4 +197,37 @@ test_expect_success 'am --abort leaves index stat info alone' '
197
git diff-files --exit-code --quiet
198
'
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
+
233
test_done