Skip to content

Commit f3a4740

Browse files
hjemliJunio C Hamano
authored andcommitted
Skip excessive blank lines before commit body
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent f367398 commit f3a4740

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

commit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
703703
const char *after_subject,
704704
int relative_date)
705705
{
706-
int hdr = 1, body = 0;
706+
int hdr = 1, body = 0, seen_title = 0;
707707
unsigned long offset = 0;
708708
int indent = 4;
709709
int parents_shown = 0;
@@ -809,6 +809,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
809809
body = 1;
810810

811811
if (is_empty_line(line, &linelen)) {
812+
if (!seen_title)
813+
continue;
812814
if (!body)
813815
continue;
814816
if (subject)
@@ -817,6 +819,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
817819
break;
818820
}
819821

822+
seen_title = 1;
820823
if (subject) {
821824
int slen = strlen(subject);
822825
memcpy(buf + offset, subject, slen);

0 commit comments

Comments
 (0)