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

[PATCH 04/12] t4013-diff-various.sh: test --stdin -z --patch

From
Kkristofferhaugsbakk@fastmail.com <kristofferhaugsbakk@fastmail.com>
Date
Dec 2, 2026, 22:14 UTC
Message-ID
<test_--stdin_-z_--patch.df3@m5gid.xyz>
In-Reply-To
<CV_diff-tree_NUL_termination.def@m5gid.xyz>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>

There aren’t any explicit tests for 'git diff-tree --stdin -z --patch'. Let’s add a couple of regression tests now since we are about to change the log-tree.c code path.[1]

† 1: Upcoming commit “log-tree: terminate cmt+diff when -z --patch”
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
 t/t4013-diff-various.sh | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 21c9ad7c5d0..928a07a91bd 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -590,6 +590,42 @@ test_expect_success 'diff-tree --stdin with pathspec' '
 	test_cmp expect actual
 '
 
+test_expect_success 'setup: diff-tree --stdin -z etc.' '
+	printf "%s" $(git rev-parse main~1) >oid1 &&
+	printf "%s" $(git rev-parse main~2) >oid2 &&
+	cat oid1 >commits &&
+	echo >>commits &&
+	cat oid2 >>commits &&
+	echo >>commits &&
+	test_line_count = 2 commits &&
+	git rev-parse main >commits2 &&
+	git rev-parse main~1 >>commits2 &&
+	test_line_count = 2 commits2 &&
+	git diff main~2 main~1 >diff1 &&
+	git diff main~3 main~2 >diff2
+'
+
+test_expect_success 'diff-tree --stdin --patch -z' '
+	cat oid1 >expect &&
+	printf "\0" >>expect &&
+	cat diff1 >>expect &&
+	cat oid2 >>expect &&
+	printf "\0" >>expect &&
+	cat diff2 >>expect &&
+	git diff-tree --stdin --patch -z <commits >actual &&
+	test_cmp_bin expect actual
+'
+
+test_expect_success 'diff-tree --stdin --patch -z --always with one empty diff' '
+	printf "%s" $(git rev-parse main) >expect &&
+	printf "\0" >>expect &&
+	printf "%s" $(git rev-parse main~1) >>expect &&
+	printf "\0" >>expect &&
+	cat diff1 >>expect &&
+	git diff-tree --stdin --patch -z --always <commits2 >actual &&
+	test_cmp_bin expect actual
+'
+
 test_expect_success 'show A B ... -- <pathspec>' '
 	# side touches dir/sub, file0, and file3
 	# main^ touches dir/sub, and file1
-- 
2.56.1.5.g155936fbb2a
Previous: kristofferhaugsbakk@fastmail.comNext: kristofferhaugsbakk@fastmail.com
Message 5 of 13 in “revision: learn -Z for NUL termination”
  1. 00/12 revision: learn -Z for NUL terminationkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  2. 01/12 t4205: use correct 'setup' keywordkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  3. 02/12 t4205: add test coverage for NUL separator and --patchkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  4. 03/12 t4205: test blank line between commit and diff explicitlykristofferhaugsbakk@fastmail.com, Dec 2, 2026
  5. 04/12 t4013-diff-various.sh: test --stdin -z --patchkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  6. 05/12 log-tree: terminate cmt+diff when -z --patchkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  7. 06/12 t4205: test --diff-mergeskristofferhaugsbakk@fastmail.com, Dec 2, 2026
  8. 07/12 revision: learn -Z for NUL terminationkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  9. 08/12 revision: split out termination characterkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  10. 09/12 diff-tree: flush each diff when --stdinkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  11. 10/12 doc: diff-tree: tell about --no-commit-id in Descriptionkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  12. 11/12 doc: diff-tree: add Examples section and mention --stdinkristofferhaugsbakk@fastmail.com, Dec 2, 2026
  13. 12/12 doc: rev-list: complete diff-tree by mentioning --alwayskristofferhaugsbakk@fastmail.com, Dec 2, 2026

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.