summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-06-27 17:03:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-27 21:41:10 (GMT)
commitd70e9c5c8c865626b6e69c2bf9fd0e368543617b (patch)
tree309b7e2255b5467662d3f3b43f74a369469a874d /t
parent44e5471a8d8ec5f04058220f8b91513b5b5accaa (diff)
downloadgit-d70e9c5c8c865626b6e69c2bf9fd0e368543617b.zip
git-d70e9c5c8c865626b6e69c2bf9fd0e368543617b.tar.gz
git-d70e9c5c8c865626b6e69c2bf9fd0e368543617b.tar.bz2
apply: check git diffs for mutually exclusive header lines
A file can either be added, removed, copied, or renamed, but no two of these actions can be done by the same patch. Some of these combinations provoke error messages due to missing file names, and some are only caught by an assertion. Check git patches already as they are parsed and report conflicting lines on sight. Found by Vegard Nossum using AFL. Reported-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4136-apply-check.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t4136-apply-check.sh b/t/t4136-apply-check.sh
index 4b0a374..6d92872 100755
--- a/t/t4136-apply-check.sh
+++ b/t/t4136-apply-check.sh
@@ -29,4 +29,22 @@ test_expect_success 'apply exits non-zero with no-op patch' '
test_must_fail git apply --check input
'
+test_expect_success 'invalid combination: create and copy' '
+ test_must_fail git apply --check - <<-\EOF
+ diff --git a/1 b/2
+ new file mode 100644
+ copy from 1
+ copy to 2
+ EOF
+'
+
+test_expect_success 'invalid combination: create and rename' '
+ test_must_fail git apply --check - <<-\EOF
+ diff --git a/1 b/2
+ new file mode 100644
+ rename from 1
+ rename to 2
+ EOF
+'
+
test_done