]>
Commit | Line | Data |
---|---|---|
cc64b318 BC |
1 | #!/bin/sh |
2 | ||
3 | test_description='git apply should exit non-zero with unrecognized input.' | |
4 | ||
f54f48fc ÆAB |
5 | |
6 | TEST_PASSES_SANITIZE_LEAK=true | |
cc64b318 BC |
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 | ||
ad6e8ed3 JH |
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 | ||
22cb3835 JS |
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 | ||
d70e9c5c RS |
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 | ||
cc64b318 | 64 | test_done |