git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/4] t4140: test apply --intent-to-add interactions

From
Raymond E. Pasco <ray@ameretat.dev>
Date
Jul 2, 2025, 21:26 UTC
Message-ID
<20250702212814.1923253-4-ray@ameretat.dev>
In-Reply-To
<20250702212814.1923253-1-ray@ameretat.dev>

Test that applying a new file creation patch to an existing index works, and that applying a patch with both modifications and new file creations works.

Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
---
 t/t4140-apply-ita.sh | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/t/t4140-apply-ita.sh b/t/t4140-apply-ita.sh
index c614eaf04c..0b11a8aef4 100755
--- a/t/t4140-apply-ita.sh
+++ b/t/t4140-apply-ita.sh
@@ -7,6 +7,10 @@ test_description='git apply of i-t-a file'
 test_expect_success setup '
 	test_write_lines 1 2 3 4 5 >blueprint &&
 
+	cat blueprint >committed-file &&
+	git add committed-file &&
+	git commit -m "commit" &&
+
 	cat blueprint >test-file &&
 	git add -N test-file &&
 	git diff >creation-patch &&
@@ -14,7 +18,14 @@ 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 &&
+	test_write_lines 6 >>committed-file &&
+	cat blueprint >test-file &&
+	git add -N test-file &&
+	git diff >complex-patch &&
+	git restore committed-file
 '
 
 test_expect_success 'apply creation patch to ita path (--cached)' '
@@ -53,4 +64,22 @@ test_expect_success 'apply deletion patch to ita path (--index)' '
 	git ls-files --stage --error-unmatch test-file
 '
 
+test_expect_success 'apply creation patch to existing index with -N' '
+	git rm -f test-file &&
+	cat blueprint >index-file &&
+	git add index-file &&
+	git apply -N creation-patch &&
+
+	git ls-files --stage --error-unmatch index-file &&
+	git ls-files --stage --error-unmatch test-file
+'
+
+test_expect_success 'apply complex patch with -N' '
+	git rm -f test-file index-file &&
+	git apply -N complex-patch &&
+
+	git ls-files --stage --error-unmatch test-file &&
+	git diff | grep "a/committed-file"
+'
+
 test_done
-- 
2.50.0.201.gfeb04032fb
Previous: Raymond E. PascoNext: Raymond E. Pasco
Message 18 of 25 in “fix apply --intent-to-add”
  1. 0/5 fix apply --intent-to-addRaymond E. Pasco, Jun 28, 2025
  2. 1/5 apply: error on --intent-to-add outside gitdirRaymond E. Pasco, Jun 28, 2025
  3. Junio C HamanoJun 30, 2025
  4. Raymond E. PascoJul 1, 2025
  5. 2/5 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jun 28, 2025
  6. Junio C HamanoJun 30, 2025
  7. Raymond E. PascoJul 1, 2025
  8. 3/5 apply: only write intents to add for new filesRaymond E. Pasco, Jun 28, 2025
  9. Junio C HamanoJun 30, 2025
  10. Raymond E. PascoJul 1, 2025
  11. 4/5 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jun 28, 2025
  12. 5/5 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jun 28, 2025
  13. Lidong YanJun 29, 2025
  14. Raymond E. PascoJun 30, 2025
  15. 0/4 fix apply --intent-to-addRaymond E. Pasco, Jul 2, 2025
  16. 1/4 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jul 2, 2025
  17. 2/4 apply: only write intents to add for new filesRaymond E. Pasco, Jul 2, 2025
  18. 3/4 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jul 2, 2025
  19. 4/4 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jul 2, 2025
  20. 0/4 fix apply --intent-to-addRaymond E. Pasco, Jul 7, 2025
  21. 1/4 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jul 7, 2025
  22. 2/4 apply: only write intents to add for new filesRaymond E. Pasco, Jul 7, 2025
  23. 3/4 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jul 7, 2025
  24. 4/4 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jul 7, 2025
  25. Junio C HamanoJul 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.