git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Shearman <rob@codeweavers.com>
To: git@vger.kernel.org
Subject: [PATCH] format-patch: Generate a newline between the subject header and the message body.
Date: Thu, 13 Jul 2006 13:03:41 +0100	[thread overview]
Message-ID: <44B6369D.6070602@codeweavers.com> (raw)

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


             reply	other threads:[~2006-07-13 12:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-13 12:03 Robert Shearman [this message]
2006-07-13 19:38 ` [PATCH] format-patch: Generate a newline between the subject header and the message body 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44B6369D.6070602@codeweavers.com \
    --to=rob@codeweavers.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).