@matheusbsbs / matheus-bagliano / commits / f3a47405bb
Fork 0

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>

Lars Hjemli committed Jan 3, 2007 at 14:34 UTC f3a47405bb27846d62d20b056817f9c7d320e2db
1 file changed +4 -1
commit.c
+4 -1
@@ -703,7 +703,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
703 const char *after_subject,
704 int relative_date)
705 {
706 - int hdr = 1, body = 0;
706 + int hdr = 1, body = 0, seen_title = 0;
707 unsigned long offset = 0;
708 int indent = 4;
709 int parents_shown = 0;
@@ -809,6 +809,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
809 body = 1;
810
811 if (is_empty_line(line, &linelen)) {
812 + if (!seen_title)
813 + continue;
814 if (!body)
815 continue;
816 if (subject)
@@ -817,6 +819,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
819 break;
820 }
821
822 + seen_title = 1;
823 if (subject) {
824 int slen = strlen(subject);
825 memcpy(buf + offset, subject, slen);