git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] format-patch: Generate a newline between the subject header and the message body.
@ 2006-07-13 12:03 Robert Shearman
  2006-07-13 19:38 ` Jakub Narebski
  2006-07-13 21:31 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 12:03 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]


format-patch previously didn't generate a newline after a subject. This 
caused the diffstat to not be displayed in messages without a blank line 
and the first blank line to be eaten in messages with a blank line.

This patch inserts a newline in two places - once in the loop to 
separate the subject part of the commit message from the body part of 
the commit message and another after the loop to counteract the eating 
of whitespace at the end of the message.
---
  commit.c |   14 ++++++++++++--
  1 files changed, 12 insertions(+), 2 deletions(-)

[-- Attachment #2: 278bfe08daa6888b9dd7c0e5ca74ad4b3c10e4a4.diff --]
[-- Type: text/x-patch, Size: 1187 bytes --]

diff --git a/commit.c b/commit.c
index 522a6f3..8869b0d 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) {
@@ -694,6 +695,9 @@ unsigned long pretty_print_commit(enum c
 			memcpy(buf + offset, after_subject, slen);
 			offset += slen;
 			after_subject = NULL;
+		} else if (fmt == CMIT_FMT_EMAIL && subject) {
+			/* separate the headers from the body */
+			buf[offset++] = '\n';
 		}
 		subject = NULL;
 	}
@@ -702,6 +706,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;
 }


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] format-patch: Generate a newline between the subject header and the message body
@ 2006-07-13 22:17 Robert Shearman
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 22:17 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]


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(-)

[-- Attachment #2: e4ec67def0af32e4a1704ce5ad941c81136b34e8.diff --]
[-- Type: text/x-patch, Size: 884 bytes --]

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;
 }


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-07-13 22:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-13 12:03 [PATCH] format-patch: Generate a newline between the subject header and the message body Robert Shearman
2006-07-13 19:38 ` Jakub Narebski
2006-07-13 20:03   ` Robert Shearman
2006-07-13 21:31 ` Junio C Hamano
2006-07-13 21:48   ` Junio C Hamano
2006-07-13 21:55     ` Robert Shearman
  -- strict thread matches above, loose matches on Subject: below --
2006-07-13 22:17 Robert Shearman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).