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

[PATCH] t4069: test diff behavior with i-t-a paths

From
Raymond E. Pasco <ray@ameretat.dev>
Date
Aug 10, 2020, 08:53 UTC
Message-ID
<20200810085343.43717-1-ray@ameretat.dev>
In-Reply-To
<20200808075323.36041-1-ray@ameretat.dev>

Add a small test suite to test the behavior of diff with intent-to-add paths. Specifically, the diff between an i-t-a entry and a file in the worktree should be a "new file" diff, and the diff between an i-t-a entry and no file in the worktree should be a "deleted file" diff. However, if --ita-visible-in-index is passed, the former should instead be a diff from the empty blob.

Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
---
 t/t4069-diff-intent-to-add.sh | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 t/t4069-diff-intent-to-add.sh
diff --git a/t/t4069-diff-intent-to-add.sh b/t/t4069-diff-intent-to-add.sh
new file mode 100644
index 0000000000..85c1a35ca7
--- /dev/null
+++ b/t/t4069-diff-intent-to-add.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='behavior of diff with intent-to-add entries'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_write_lines 1 2 3 4 5 >blueprint
+'
+
+test_expect_success 'diff between i-t-a and file should be new file' '
+	cat blueprint >test-file &&
+	git add -N test-file &&
+	git diff >output &&
+	grep "new file mode 100644" output
+'
+
+test_expect_success 'diff between i-t-a and no file should be deletion' '
+	rm -f test-file &&
+	git diff >output &&
+	grep "deleted file mode 100644" output
+'
+
+test_expect_success '--ita-visible-in-index diff should be from empty blob' '
+	cat blueprint >test-file &&
+	git diff --ita-visible-in-index >output &&
+	grep "index e69de29" output
+'
+
+test_done
-- 
2.28.0.3.gc4aba908ca
Previous: Junio C HamanoNext: Raymond E. Pasco
Message 39 of 53 in “apply: Allow "new file" patches on i-t-a entries”
  1. apply: Allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  2. Junio C HamanoAug 4, 2020
  3. Raymond E. PascoAug 4, 2020
  4. apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  5. apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  6. Junio C HamanoAug 4, 2020
  7. Raymond E. PascoAug 5, 2020
  8. 0/3 apply: handle i-t-a entries in indexRaymond E. Pasco, Aug 6, 2020
  9. 1/3 apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 6, 2020
  10. 2/3 apply: make i-t-a entries never match worktreeRaymond E. Pasco, Aug 6, 2020
  11. Junio C HamanoAug 6, 2020
  12. Raymond E. PascoAug 6, 2020
  13. 3/3 t4140: test apply with i-t-a pathsRaymond E. Pasco, Aug 6, 2020
  14. Junio C HamanoAug 6, 2020
  15. Raymond E. PascoAug 7, 2020
  16. 0/3 apply: handle i-t-a entries in indexRaymond E. Pasco, Aug 8, 2020
  17. 1/3 apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  18. Phillip WoodAug 8, 2020
  19. 2/3 apply: make i-t-a entries never match worktreeRaymond E. Pasco, Aug 8, 2020
  20. Phillip WoodAug 8, 2020
  21. Raymond E. PascoAug 8, 2020
  22. Phillip WoodAug 8, 2020
  23. Raymond E. PascoAug 8, 2020
  24. Phillip WoodAug 9, 2020
  25. Junio C HamanoAug 9, 2020
  26. git-apply.txt: correct description of --cachedRaymond E. Pasco, Aug 10, 2020
  27. Junio C HamanoAug 10, 2020
  28. Phillip WoodAug 12, 2020
  29. Junio C HamanoAug 12, 2020
  30. Raymond E. PascoAug 12, 2020
  31. Phillip WoodAug 12, 2020
  32. 3/3 t4140: test apply with i-t-a pathsRaymond E. Pasco, Aug 8, 2020
  33. Phillip WoodAug 23, 2020
  34. 1/1 diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  35. Martin ÅgrenAug 8, 2020
  36. Raymond E. PascoAug 8, 2020
  37. Martin ÅgrenAug 8, 2020
  38. Junio C HamanoAug 9, 2020
  39. t4069: test diff behavior with i-t-a pathsRaymond E. Pasco, Aug 10, 2020
  40. diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 10, 2020
  41. diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 10, 2020
  42. Junio C HamanoAug 10, 2020
  43. Eric SunshineAug 10, 2020
  44. Eric SunshineAug 10, 2020
  45. Junio C HamanoAug 10, 2020
  46. Eric SunshineAug 10, 2020
  47. Junio C HamanoAug 10, 2020
  48. Raymond E. PascoAug 10, 2020
  49. Eric SunshineAug 10, 2020
  50. Junio C HamanoAug 11, 2020
  51. 0/2 apply: reject modification diffs to i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  52. 1/2 apply: reject modification diffs to i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  53. 2/2 t4140: test failure of diff from empty blob to i-t-a pathRaymond E. Pasco, Aug 8, 2020

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.