]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t4151: add a few am --abort tests
authorElijah Newren <newren@gmail.com>
Fri, 10 Sep 2021 10:31:15 +0000 (10:31 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Sep 2021 22:51:15 +0000 (15:51 -0700)
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4151-am-abort.sh

index 9d8d3c72e7efe68b8e0011c1ec9b77d9a0820b30..15f2f92cd76b177ae2cff6d943a04a6ba7ef02fd 100755 (executable)
@@ -23,7 +23,13 @@ test_expect_success setup '
                test_tick &&
                git commit -a -m $i || return 1
        done &&
+       git branch changes &&
        git format-patch --no-numbered initial &&
+       git checkout -b conflicting initial &&
+       echo different >>file-1 &&
+       echo whatever >new-file &&
+       git add file-1 new-file &&
+       git commit -m different &&
        git checkout -b side initial &&
        echo local change >file-2-expect
 '
@@ -191,4 +197,37 @@ test_expect_success 'am --abort leaves index stat info alone' '
        git diff-files --exit-code --quiet
 '
 
+test_expect_failure 'git am --abort return failed exit status when it fails' '
+       test_when_finished "rm -rf file-2/ && git reset --hard && git am --abort" &&
+       git checkout changes &&
+       git format-patch -1 --stdout conflicting >changes.mbox &&
+       test_must_fail git am --3way changes.mbox &&
+
+       git rm file-2 &&
+       mkdir file-2 &&
+       echo precious >file-2/somefile &&
+       test_must_fail git am --abort &&
+       test_path_is_dir file-2/
+'
+
+test_expect_success 'git am --abort cleans relevant files' '
+       git checkout changes &&
+       git format-patch -1 --stdout conflicting >changes.mbox &&
+       test_must_fail git am --3way changes.mbox &&
+
+       test_path_is_file new-file &&
+       echo further changes >>file-1 &&
+       echo change other file >>file-2 &&
+
+       # Abort, and expect the files touched by am to be reverted
+       git am --abort &&
+
+       test_path_is_missing new-file &&
+
+       # Files not involved in am operation are left modified
+       git diff --name-only changes >actual &&
+       test_write_lines file-2 >expect &&
+       test_cmp expect actual
+'
+
 test_done