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

shortlog: handle multi-line subjects like log --pretty=oneline et. al. do

The commit message parser of git shortlog used to treat only the first non-empty line of the commit message as the subject. Other log commands (e.g. --pretty=oneline) show the whole first paragraph instead (unwrapped into a single line). For consistency, this patch borrows format_subject() from pretty.c to make shortlog do the same. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 6, 2009 at 21:41 UTC cec08717cca468c66eb454c7201fd35f54b48a58
2 files changed +8 -5
builtin-shortlog.c
+6 -3
@@ -29,6 +29,9 @@ static int compare_by_number(const void *a1, const void *a2)
29 return -1;
30 }
31
32 +const char *format_subject(struct strbuf *sb, const char *msg,
33 + const char *line_separator);
34 +
35 static void insert_one_record(struct shortlog *log,
36 const char *author,
37 const char *oneline)
@@ -41,6 +44,7 @@ static void insert_one_record(struct shortlog *log,
44 size_t len;
45 const char *eol;
46 const char *boemail, *eoemail;
47 + struct strbuf subject = STRBUF_INIT;
48
49 boemail = strchr(author, '<');
50 if (!boemail)
@@ -89,9 +93,8 @@ static void insert_one_record(struct shortlog *log,
93 while (*oneline && isspace(*oneline) && *oneline != '\n')
94 oneline++;
95 len = eol - oneline;
92 - while (len && isspace(oneline[len-1]))
93 - len--;
94 - buffer = xmemdupz(oneline, len);
96 + format_subject(&subject, oneline, " ");
97 + buffer = strbuf_detach(&subject, NULL);
98
99 if (dot3) {
100 int dot3len = strlen(dot3);
pretty.c
+2 -2
@@ -486,8 +486,8 @@ static void parse_commit_header(struct format_commit_context *context)
486 context->commit_header_parsed = 1;
487 }
488
489 -static const char *format_subject(struct strbuf *sb, const char *msg,
490 - const char *line_separator)
489 +const char *format_subject(struct strbuf *sb, const char *msg,
490 + const char *line_separator)
491 {
492 int first = 1;
493