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

[PATCH] Skip excessive blank lines before commit body

From
LHLars Hjemli <hjemli@gmail.com>
Date
Jan 3, 2007, 13:34 UTC
Message-ID
<11678312532251-git-send-email-hjemli@gmail.com>

This modifies pretty_print_commit() to make the output of git-rev-list and friends a bit more predictable.

A commit body starting with blank lines might be unheard-of, but still possible to create using git-commit-tree (so is bound to appear somewhere, sometime).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 commit.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/commit.c b/commit.c
index 544e426..2a58175 100644
--- a/commit.c
+++ b/commit.c
@@ -703,7 +703,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 				  const char *after_subject,
 				  int relative_date)
 {
-	int hdr = 1, body = 0;
+	int hdr = 1, body = 0, seen_title = 0;
 	unsigned long offset = 0;
 	int indent = 4;
 	int parents_shown = 0;
@@ -809,6 +809,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 			body = 1;
 
 		if (is_empty_line(line, &linelen)) {
+			if (!seen_title)
+				continue;
 			if (!body)
 				continue;
 			if (subject)
@@ -817,6 +819,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
 				break;
 		}
 
+		seen_title = 1;
 		if (subject) {
 			int slen = strlen(subject);
 			memcpy(buf + offset, subject, slen);
-- 
1.5.0.rc0.ge900
Next: Junio C Hamano
Message 1 of 3 in “Skip excessive blank lines before commit body”
  1. Skip excessive blank lines before commit bodyLars Hjemli, Jan 3, 2007
  2. Junio C HamanoJan 3, 2007
  3. Andreas EricssonJan 4, 2007

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.