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

[PATCH 03/12] t4205: test blank line between commit and diff explicitly

From
Kkristofferhaugsbakk@fastmail.com <kristofferhaugsbakk@fastmail.com>
Date
Dec 2, 2026, 22:14 UTC
Message-ID
<blank_line.df2@m5gid.xyz>
In-Reply-To
<CV_diff-tree_NUL_termination.def@m5gid.xyz>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
This comment and code in log-tree.c:
    When showing a verbose header (i.e. log message), [...] we would
    want an extra newline between the end of log and the diff/diffstat
    output for readability.
is not directly tested by this file. There are two cases:
1. Terminators
2. Separator (--pretty=format:<fmt>)

Case (1) is tested by 'NUL separation with --stat'. Let’s add an explicit test for that which doesn’t use special flags like -z.

Case (2) does not adhere to the comment above, though. There is no blank line between the commit message and the diff:

    $ git log --patch --pretty=format:<fmt>
    <subject>
    <diff>

The reason is that terminators are added after show_log(...), i.e. after the log message, while separators are added at the beginning of show_log(...). This is how newlines work for terminators:

1. Custom format is printed; missing newline
2. The code below this comment terminates the commit log
3. The terminator newline adds a blank line
4. The diff is printed
While the separator case is missing step (3).

That might be a bug judging by this code comment. But changing it would break several *other* tests. Let’s just add a regression test at this point.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
 t/t4205-log-pretty-formats.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 5048c3b4c39..b03dd647ee4 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -118,6 +118,21 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
+test_expect_success 'log --format=%s --patch blank line between commit and diff' '
+	git log --format=%s -1 >expect &&
+	echo >>expect &&
+	git diff HEAD^ HEAD >>expect &&
+	git log --format=%s --patch -1 >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'log --pretty=format:%s --patch no blank line between commit and diff' '
+	git log --format=%s -1 >expect &&
+	git diff HEAD^ HEAD >>expect &&
+	git log --pretty=format:%s --patch -1 >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
-- 
2.56.1.5.g155936fbb2a
Previous: kristofferhaugsbakk@fastmail.comNext: kristofferhaugsbakk@fastmail.com
Message 4 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.