From: Junio C Hamano Date: Sun, 18 Jan 2009 07:05:23 +0000 (-0800) Subject: Merge branch 'rs/maint-shortlog-foldline' X-Git-Tag: v1.6.2-rc0~142 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b4147b3af24852250632ec4ed7e41c608aa8c6a3?ds=inline;hp=-c Merge branch 'rs/maint-shortlog-foldline' * rs/maint-shortlog-foldline: shortlog: handle multi-line subjects like log --pretty=oneline et. al. do --- b4147b3af24852250632ec4ed7e41c608aa8c6a3 diff --combined builtin-shortlog.c index 90e76ae420,e49290687f..5f9f3f09b1 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@@ -29,6 -29,9 +29,9 @@@ static int compare_by_number(const voi return -1; } + const char *format_subject(struct strbuf *sb, const char *msg, + const char *line_separator); + static void insert_one_record(struct shortlog *log, const char *author, const char *oneline) @@@ -36,10 -39,12 +39,11 @@@ const char *dot3 = log->common_repo_prefix; char *buffer, *p; struct string_list_item *item; - struct string_list *onelines; char namebuf[1024]; size_t len; const char *eol; const char *boemail, *eoemail; + struct strbuf subject = STRBUF_INIT; boemail = strchr(author, '<'); if (!boemail) @@@ -67,9 -72,12 +71,9 @@@ snprintf(namebuf + len, room, " %.*s", maillen, boemail); } - buffer = xstrdup(namebuf); - item = string_list_insert(buffer, &log->list); + item = string_list_insert(namebuf, &log->list); if (item->util == NULL) item->util = xcalloc(1, sizeof(struct string_list)); - else - free(buffer); /* Skip any leading whitespace, including any blank lines. */ while (*oneline && isspace(*oneline)) @@@ -85,9 -93,8 +89,8 @@@ while (*oneline && isspace(*oneline) && *oneline != '\n') oneline++; len = eol - oneline; - while (len && isspace(oneline[len-1])) - len--; - buffer = xmemdupz(oneline, len); + format_subject(&subject, oneline, " "); + buffer = strbuf_detach(&subject, NULL); if (dot3) { int dot3len = strlen(dot3); @@@ -100,7 -107,16 +103,7 @@@ } } - onelines = item->util; - if (onelines->nr >= onelines->alloc) { - onelines->alloc = alloc_nr(onelines->nr); - onelines->items = xrealloc(onelines->items, - onelines->alloc - * sizeof(struct string_list_item)); - } - - onelines->items[onelines->nr].util = NULL; - onelines->items[onelines->nr++].string = buffer; + string_list_append(buffer, item->util); } static void read_from_stdin(struct shortlog *log) @@@ -310,7 -326,7 +313,7 @@@ void shortlog_output(struct shortlog *l } onelines->strdup_strings = 1; - string_list_clear(onelines, 1); + string_list_clear(onelines, 0); free(onelines); log->list.items[i].util = NULL; }