Skip to content

Commit a4c969a

Browse files
jupedgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c6e61f commit a4c969a

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

t/t4140-apply-ita.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,25 @@ test_description='git apply of i-t-a file'
77
test_expect_success setup '
88
test_write_lines 1 2 3 4 5 >blueprint &&
99
10+
cat blueprint >committed-file &&
11+
git add committed-file &&
12+
git commit -m "commit" &&
13+
1014
cat blueprint >test-file &&
1115
git add -N test-file &&
1216
git diff >creation-patch &&
1317
grep "new file mode 100644" creation-patch &&
1418
1519
rm -f test-file &&
1620
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
1829
'
1930

2031
test_expect_success 'apply creation patch to ita path (--cached)' '
@@ -53,4 +64,22 @@ test_expect_success 'apply deletion patch to ita path (--index)' '
5364
git ls-files --stage --error-unmatch test-file
5465
'
5566

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"
83+
'
84+
5685
test_done

0 commit comments

Comments
 (0)