[HYPOTHETICAL,2/2] t4140: test failure of diff from empty blob to i-t-a path
diff mbox series

Message ID 20200808075827.36248-3-ray@ameretat.dev
State New
Headers show
Series
  • apply: reject modification diffs to i-t-a entries
Related show

Commit Message

Raymond E. Pasco Aug. 8, 2020, 7:58 a.m. UTC
"git apply" should only accept new file or deleted file patches to an
i-t-a index entry.

Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
---
 t/t4140-apply-ita.sh | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh
index c614eaf04c..898dd251b4 100755
--- a/t/t4140-apply-ita.sh
+++ b/t/t4140-apply-ita.sh
@@ -14,7 +14,13 @@  test_expect_success setup '
 
 	rm -f test-file &&
 	git diff >deletion-patch &&
-	grep "deleted file mode 100644" deletion-patch
+	grep "deleted file mode 100644" deletion-patch &&
+
+	git rm -f test-file &&
+	touch test-file &&
+	git add test-file &&
+	cat blueprint >test-file &&
+	git diff >incorrect-patch
 '
 
 test_expect_success 'apply creation patch to ita path (--cached)' '
@@ -27,6 +33,14 @@  test_expect_success 'apply creation patch to ita path (--cached)' '
 	test_cmp blueprint actual
 '
 
+test_expect_success 'apply diff from empty blob to ita path (--cached)' '
+	git rm -f test-file &&
+	cat blueprint >test-file &&
+	git add -N test-file &&
+
+	test_must_fail git apply --cached incorrect-patch
+'
+
 test_expect_success 'apply creation patch to ita path (--index)' '
 	git rm -f test-file &&
 	cat blueprint >test-file &&