@matheusbsbs / matheus-bagliano / commits / 19b3bd3e2d
Fork 0

format-patch: Generate a newline between the subject header and the message 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>

Robert Shearman committed Jul 13, 2006 at 23:17 UTC 19b3bd3e2d260323c5e727212a6dcd7fc0f7aa07
1 file changed +9 -2
commit.c
+9 -2
@@ -655,6 +655,9 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
655 continue;
656 }
657
658 + if (!subject)
659 + body = 1;
660 +
661 if (is_empty_line(line, &linelen)) {
662 if (!body)
663 continue;
@@ -662,8 +665,6 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
665 continue;
666 if (fmt == CMIT_FMT_SHORT)
667 break;
665 - } else {
666 - body = 1;
668 }
669
670 if (subject) {
@@ -702,6 +703,12 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
703 /* Make sure there is an EOLN for the non-oneline case */
704 if (fmt != CMIT_FMT_ONELINE)
705 buf[offset++] = '\n';
706 + /*
707 + * make sure there is another EOLN to separate the headers from whatever
708 + * body the caller appends if we haven't already written a body
709 + */
710 + if (fmt == CMIT_FMT_EMAIL && !body)
711 + buf[offset++] = '\n';
712 buf[offset] = '\0';
713 return offset;
714 }