Merge branch 'maint'
[gitweb.git] / t / t4117-apply-reject.sh
index e9ccd161ee96a5bdbb4bf77de406ea51dacfb5de..d80187de9446c3129e1c69d3b67278f2fd40c9a0 100755 (executable)
@@ -46,25 +46,23 @@ test_expect_success setup '
        cat file1 >saved.file1
 '
 
-test_expect_success 'apply without --reject should fail' '
+test_expect_success 'apply --reject is incompatible with --3way' '
+       test_when_finished "cat saved.file1 >file1" &&
+       git diff >patch.0 &&
+       git checkout file1 &&
+       test_must_fail git apply --reject --3way patch.0 &&
+       git diff --exit-code
+'
 
-       if git apply patch.1
-       then
-               echo "Eh? Why?"
-               exit 1
-       fi
+test_expect_success 'apply without --reject should fail' '
 
+       test_must_fail git apply patch.1 &&
        test_cmp file1 saved.file1
 '
 
 test_expect_success 'apply without --reject should fail' '
 
-       if git apply --verbose patch.1
-       then
-               echo "Eh? Why?"
-               exit 1
-       fi
-
+       test_must_fail git apply --verbose patch.1 &&
        test_cmp file1 saved.file1
 '
 
@@ -73,21 +71,11 @@ test_expect_success 'apply with --reject should fail but update the file' '
        cat saved.file1 >file1 &&
        rm -f file1.rej file2.rej &&
 
-       if git apply --reject patch.1
-       then
-               echo "succeeds with --reject?"
-               exit 1
-       fi
-
+       test_must_fail git apply --reject patch.1 &&
        test_cmp file1 expected &&
 
        cat file1.rej &&
-
-       if test -f file2.rej
-       then
-               echo "file2 should not have been touched"
-               exit 1
-       fi
+       test_path_is_missing file2.rej
 '
 
 test_expect_success 'apply with --reject should fail but update the file' '
@@ -95,25 +83,12 @@ test_expect_success 'apply with --reject should fail but update the file' '
        cat saved.file1 >file1 &&
        rm -f file1.rej file2.rej file2 &&
 
-       if git apply --reject patch.2 >rejects
-       then
-               echo "succeeds with --reject?"
-               exit 1
-       fi
-
-       test -f file1 && {
-               echo "file1 still exists?"
-               exit 1
-       }
+       test_must_fail git apply --reject patch.2 >rejects &&
+       test_path_is_missing file1 &&
        test_cmp file2 expected &&
 
        cat file2.rej &&
-
-       if test -f file1.rej
-       then
-               echo "file2 should not have been touched"
-               exit 1
-       fi
+       test_path_is_missing file1.rej
 
 '
 
@@ -122,25 +97,12 @@ test_expect_success 'the same test with --verbose' '
        cat saved.file1 >file1 &&
        rm -f file1.rej file2.rej file2 &&
 
-       if git apply --reject --verbose patch.2 >rejects
-       then
-               echo "succeeds with --reject?"
-               exit 1
-       fi
-
-       test -f file1 && {
-               echo "file1 still exists?"
-               exit 1
-       }
+       test_must_fail git apply --reject --verbose patch.2 >rejects &&
+       test_path_is_missing file1 &&
        test_cmp file2 expected &&
 
        cat file2.rej &&
-
-       if test -f file1.rej
-       then
-               echo "file2 should not have been touched"
-               exit 1
-       fi
+       test_path_is_missing file1.rej
 
 '