]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4136-apply-check.sh
Merge https://github.com/prati0100/git-gui
[thirdparty/git.git] / t / t4136-apply-check.sh
1 #!/bin/sh
2
3 test_description='git apply should exit non-zero with unrecognized input.'
4
5
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
8
9 test_expect_success 'setup' '
10 test_commit 1
11 '
12
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
19 '
20
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 @@
28 1
29 EOF
30 test_must_fail git apply --stat input &&
31 test_must_fail git apply --check input
32 '
33
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 @@
42 1
43 EOF
44 '
45
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
53 '
54
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
62 '
63
64 test_done