Brandon Casey | cc64b31 | 2011-12-03 14:35:50 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git apply should exit non-zero with unrecognized input.' |
| 4 | |
Ævar Arnfjörð Bjarmason | f54f48f | 2021-10-31 00:24:18 +0200 | [diff] [blame] | 5 | |
| 6 | TEST_PASSES_SANITIZE_LEAK=true |
Brandon Casey | cc64b31 | 2011-12-03 14:35:50 -0600 | [diff] [blame] | 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 | |
Junio C Hamano | ad6e8ed | 2015-06-01 12:12:04 -0700 | [diff] [blame] | 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 | |
Johannes Schindelin | 22cb383 | 2018-11-12 12:54:49 -0800 | [diff] [blame] | 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 | |
René Scharfe | d70e9c5 | 2017-06-27 19:03:39 +0200 | [diff] [blame] | 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 | |
Brandon Casey | cc64b31 | 2011-12-03 14:35:50 -0600 | [diff] [blame] | 64 | test_done |