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

[PATCH] format-patch: Generate a newline between the subject header and the message body

From
RSRobert Shearman <rob@codeweavers.com>
Date
Jul 13, 2006, 22:17 UTC
Message-ID
<44B6C672.9090300@codeweavers.com>
format-patch previously didn't generate a newline after a subject. This 
caused the diffstat to not be displayed in messages with only one line 
for the commit message.
This patch fixes this by adding a newline after the headers if a body 
hasn't been added.
Signed-off-by: Robert Shearman <rob@codeweavers.com>
---
  commit.c |   11 +++++++++--
  1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 522a6f3..6ac3bf7 100644
--- a/commit.c
+++ b/commit.c
@@ -655,6 +655,9 @@ unsigned long pretty_print_commit(enum c
 			continue;
 		}
 
+		if (!subject)
+			body = 1;
+
 		if (is_empty_line(line, &linelen)) {
 			if (!body)
 				continue;
@@ -662,8 +665,6 @@ unsigned long pretty_print_commit(enum c
 				continue;
 			if (fmt == CMIT_FMT_SHORT)
 				break;
-		} else {
-			body = 1;
 		}
 
 		if (subject) {
@@ -702,6 +703,12 @@ unsigned long pretty_print_commit(enum c
 	/* Make sure there is an EOLN for the non-oneline case */
 	if (fmt != CMIT_FMT_ONELINE)
 		buf[offset++] = '\n';
+	/*
+	 * make sure there is another EOLN to separate the headers from whatever
+	 * body the caller appends if we haven't already written a body
+	 */
+	if (fmt == CMIT_FMT_EMAIL && !body)
+		buf[offset++] = '\n';
 	buf[offset] = '\0';
 	return offset;
 }
Message 1 of 1 in “format-patch: Generate a newline between the subject header and the message body”
  1. format-patch: Generate a newline between the subject header and the message bodyRobert Shearman, Jul 13, 2006

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.