[HYPOTHETICAL PATCH 2/2] t4140: test failure of diff from empty blob to i-t-a path
- From
Raymond E. Pasco <ray@ameretat.dev>
- Date
- Aug 8, 2020, 07:58 UTC
- Message-ID
- <20200808075827.36248-3-ray@ameretat.dev>
- In-Reply-To
- <20200808075827.36248-1-ray@ameretat.dev>
"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(-)
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 &&
-- 2.28.0.5.gfc8e108108