t8*: adjust the references to the default branch name "main"
[git] / t / t4136-apply-check.sh
1 #!/bin/sh
2
3 test_description='git apply should exit non-zero with unrecognized input.'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         test_commit 1
9 '
10
11 test_expect_success 'apply --check exits non-zero with unrecognized input' '
12         test_must_fail git apply --check - <<-\EOF
13         I am not a patch
14         I look nothing like a patch
15         git apply must fail
16         EOF
17 '
18
19 test_expect_success 'apply exits non-zero with no-op patch' '
20         cat >input <<-\EOF &&
21         diff --get a/1 b/1
22         index 6696ea4..606eddd 100644
23         --- a/1
24         +++ b/1
25         @@ -1,1 +1,1 @@
26          1
27         EOF
28         test_must_fail git apply --stat input &&
29         test_must_fail git apply --check input
30 '
31
32 test_expect_success '`apply --recount` allows no-op patch' '
33         echo 1 >1 &&
34         git apply --recount --check <<-\EOF
35         diff --get a/1 b/1
36         index 6696ea4..606eddd 100644
37         --- a/1
38         +++ b/1
39         @@ -1,1 +1,1 @@
40          1
41         EOF
42 '
43
44 test_expect_success 'invalid combination: create and copy' '
45         test_must_fail git apply --check - <<-\EOF
46         diff --git a/1 b/2
47         new file mode 100644
48         copy from 1
49         copy to 2
50         EOF
51 '
52
53 test_expect_success 'invalid combination: create and rename' '
54         test_must_fail git apply --check - <<-\EOF
55         diff --git a/1 b/2
56         new file mode 100644
57         rename from 1
58         rename to 2
59         EOF
60 '
61
62 test_done