Git fork

t4140: test apply --intent-to-add interactions

Test that applying a new file creation patch with --intent-to-add to
an existing index does not modify the index outside adding the correct
intents-to-add, and that applying a patch with both modifications
and new file creations with --intent-to-add correctly only adds
intents-to-add to the index.

Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Raymond E. Pasco and committed by
Junio C Hamano
a4c969aa 7c6e61f8

+30 -1
+30 -1
t/t4140-apply-ita.sh
··· 7 7 test_expect_success setup ' 8 8 test_write_lines 1 2 3 4 5 >blueprint && 9 9 10 + cat blueprint >committed-file && 11 + git add committed-file && 12 + git commit -m "commit" && 13 + 10 14 cat blueprint >test-file && 11 15 git add -N test-file && 12 16 git diff >creation-patch && ··· 14 18 15 19 rm -f test-file && 16 20 git diff >deletion-patch && 17 - grep "deleted file mode 100644" deletion-patch 21 + grep "deleted file mode 100644" deletion-patch && 22 + 23 + git rm -f test-file && 24 + test_write_lines 6 >>committed-file && 25 + cat blueprint >test-file && 26 + git add -N test-file && 27 + git diff >complex-patch && 28 + git restore committed-file 18 29 ' 19 30 20 31 test_expect_success 'apply creation patch to ita path (--cached)' ' ··· 51 62 52 63 test_must_fail git apply --index deletion-patch && 53 64 git ls-files --stage --error-unmatch test-file 65 + ' 66 + 67 + test_expect_success 'apply creation patch to existing index with -N' ' 68 + git rm -f test-file && 69 + cat blueprint >index-file && 70 + git add index-file && 71 + git apply -N creation-patch && 72 + 73 + git ls-files --stage --error-unmatch index-file && 74 + git ls-files --stage --error-unmatch test-file 75 + ' 76 + 77 + test_expect_success 'apply complex patch with -N' ' 78 + git rm -f test-file index-file && 79 + git apply -N complex-patch && 80 + 81 + git ls-files --stage --error-unmatch test-file && 82 + git diff | grep "a/committed-file" 54 83 ' 55 84 56 85 test_done