Git 2.45
[git/gitster.git] / t / t4136-apply-check.sh
blobdfec1c5f0f63fca3b0f0f47d2296be93c0e4f1ed
1 #!/bin/sh
3 test_description='git apply should exit non-zero with unrecognized input.'
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 test_expect_success 'setup' '
10 test_commit 1
13 test_expect_success 'apply --check exits non-zero with unrecognized input' '
14 test_must_fail git apply --check - <<-\EOF
15 I am not a patch
16 I look nothing like a patch
17 git apply must fail
18 EOF
21 test_expect_success 'apply exits non-zero with no-op patch' '
22 cat >input <<-\EOF &&
23 diff --get a/1 b/1
24 index 6696ea4..606eddd 100644
25 --- a/1
26 +++ b/1
27 @@ -1,1 +1,1 @@
29 EOF
30 test_must_fail git apply --stat input &&
31 test_must_fail git apply --check input
34 test_expect_success '`apply --recount` allows no-op patch' '
35 echo 1 >1 &&
36 git apply --recount --check <<-\EOF
37 diff --get a/1 b/1
38 index 6696ea4..606eddd 100644
39 --- a/1
40 +++ b/1
41 @@ -1,1 +1,1 @@
43 EOF
46 test_expect_success 'invalid combination: create and copy' '
47 test_must_fail git apply --check - <<-\EOF
48 diff --git a/1 b/2
49 new file mode 100644
50 copy from 1
51 copy to 2
52 EOF
55 test_expect_success 'invalid combination: create and rename' '
56 test_must_fail git apply --check - <<-\EOF
57 diff --git a/1 b/2
58 new file mode 100644
59 rename from 1
60 rename to 2
61 EOF
64 test_done