From: Junio C Hamano Date: Sun, 7 Mar 2010 22:53:45 +0000 (-0800) Subject: Merge branch 'rs/optim-text-wrap' into maint-1.6.6 X-Git-Tag: v1.7.0.3~33^2~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/11a1a49a16a52ff9b684a430d68b8982ed313427?ds=inline;hp=-c Merge branch 'rs/optim-text-wrap' into maint-1.6.6 * rs/optim-text-wrap: utf8.c: speculatively assume utf-8 in strbuf_add_wrapped_text() utf8.c: remove strbuf_write() utf8.c: remove print_spaces() utf8.c: remove print_wrapped_text() --- 11a1a49a16a52ff9b684a430d68b8982ed313427 diff --combined builtin-shortlog.c index b3b055f68c,d96858f9ad..ecd2d45a00 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@@ -139,12 -139,8 +139,12 @@@ static void read_from_stdin(struct shor void shortlog_add_commit(struct shortlog *log, struct commit *commit) { const char *author = NULL, *buffer; + struct strbuf buf = STRBUF_INIT; + struct strbuf ufbuf = STRBUF_INIT; + struct pretty_print_context ctx = {0}; - buffer = commit->buffer; + pretty_print_commit(CMIT_FMT_RAW, commit, &buf, &ctx); + buffer = buf.buf; while (*buffer && *buffer != '\n') { const char *eol = strchr(buffer, '\n'); @@@ -161,19 -157,20 +161,19 @@@ die("Missing author: %s", sha1_to_hex(commit->object.sha1)); if (log->user_format) { - struct strbuf buf = STRBUF_INIT; struct pretty_print_context ctx = {0}; ctx.abbrev = DEFAULT_ABBREV; ctx.subject = ""; ctx.after_subject = ""; ctx.date_mode = DATE_NORMAL; - pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf, &ctx); - insert_one_record(log, author, buf.buf); - strbuf_release(&buf); - return; - } - if (*buffer) + pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf, &ctx); + buffer = ufbuf.buf; + } else if (*buffer) { buffer++; + } insert_one_record(log, author, !*buffer ? "" : buffer); + strbuf_release(&ufbuf); + strbuf_release(&buf); } static void get_from_rev(struct rev_info *rev, struct shortlog *log) @@@ -304,9 -301,19 +304,19 @@@ parse_done return 0; } + static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s, + const struct shortlog *log) + { + int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap); + if (col != log->wrap) + strbuf_addch(sb, '\n'); + } + void shortlog_output(struct shortlog *log) { int i, j; + struct strbuf sb = STRBUF_INIT; + if (log->sort_by_number) qsort(log->list.items, log->list.nr, sizeof(struct string_list_item), compare_by_number); @@@ -321,9 -328,9 +331,9 @@@ const char *msg = onelines->items[j].string; if (log->wrap_lines) { - int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap); - if (col != log->wrap) - putchar('\n'); + strbuf_reset(&sb); + add_wrapped_shortlog_msg(&sb, msg, log); + fwrite(sb.buf, sb.len, 1, stdout); } else printf(" %s\n", msg); @@@ -337,6 -344,7 +347,7 @@@ log->list.items[i].util = NULL; } + strbuf_release(&sb); log->list.strdup_strings = 1; string_list_clear(&log->list, 1); clear_mailmap(&log->mailmap);