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>
Raymond E. Pasco committed
Jul 7, 2025 at 08:12 UTC
a4c969aa0d9c98ed29ea495fa0bae61bfbc713fe
1 file changed
+30
-1
t/t4140-apply-ita.sh
+30
-1
@@ -7,6 +7,10 @@ test_description='git apply of i-t-a file'
7
test_expect_success setup '
8
test_write_lines 1 2 3 4 5 >blueprint &&
9
10
+ cat blueprint >committed-file &&
11
+ git add committed-file &&
12
+ git commit -m "commit" &&
13
+
14
cat blueprint >test-file &&
15
git add -N test-file &&
16
git diff >creation-patch &&
@@ -14,7 +18,14 @@ test_expect_success setup '
18
19
rm -f test-file &&
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
29
'
30
31
test_expect_success 'apply creation patch to ita path (--cached)' '
@@ -53,4 +64,22 @@ test_expect_success 'apply deletion patch to ita path (--index)' '
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"
83
+'
84
+
85
test_done