Skip to content

Commit

Permalink
Skip excessive blank lines before commit body
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars Hjemli authored and Junio C Hamano committed Jan 3, 2007
1 parent f367398 commit f3a4740
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
const char *after_subject,
int relative_date)
{
int hdr = 1, body = 0;
int hdr = 1, body = 0, seen_title = 0;
unsigned long offset = 0;
int indent = 4;
int parents_shown = 0;
Expand Down Expand Up @@ -809,6 +809,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
body = 1;

if (is_empty_line(line, &linelen)) {
if (!seen_title)
continue;
if (!body)
continue;
if (subject)
Expand All @@ -817,6 +819,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
break;
}

seen_title = 1;
if (subject) {
int slen = strlen(subject);
memcpy(buf + offset, subject, slen);
Expand Down

0 comments on commit f3a4740

Please sign in to comment.