Skip to content

Commit

Permalink
format-patch: Generate a newline between the subject header and the m…
Browse files Browse the repository at this point in the history
…essage body

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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Robert Shearman authored and Junio C Hamano committed Jul 14, 2006
1 parent a40d384 commit 19b3bd3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,16 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
continue;
}

if (!subject)
body = 1;

if (is_empty_line(line, &linelen)) {
if (!body)
continue;
if (subject)
continue;
if (fmt == CMIT_FMT_SHORT)
break;
} else {
body = 1;
}

if (subject) {
Expand Down Expand Up @@ -702,6 +703,12 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
/* 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;
}
Expand Down

0 comments on commit 19b3bd3

Please sign in to comment.