From: Junio C Hamano Date: Fri, 29 Jan 2016 00:10:14 +0000 (-0800) Subject: Merge branch 'jk/shortlog' X-Git-Tag: v2.8.0-rc0~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1c5405a522858af39036cde8af37bbe1aaa9a38;p=git Merge branch 'jk/shortlog' "git shortlog" used to accumulate various pieces of information regardless of what was asked to be shown in the final output. It has been optimized by noticing what need not to be collected (e.g. there is no need to collect the log messages when showing only the number of changes). * jk/shortlog: shortlog: don't warn on empty author shortlog: optimize out useless string list shortlog: optimize out useless "" normalization shortlog: optimize "--summary" mode shortlog: replace hand-parsing of author with pretty-printer shortlog: use strbufs to read from stdin shortlog: match both "Author:" and "author" on stdin --- a1c5405a522858af39036cde8af37bbe1aaa9a38 diff --cc builtin/shortlog.c index 35ebd17f80,e32be3993c..bfc082e584 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@@ -91,20 -115,24 +115,24 @@@ static void insert_one_record(struct sh static void read_from_stdin(struct shortlog *log) { - char author[1024], oneline[1024]; + struct strbuf author = STRBUF_INIT; + struct strbuf oneline = STRBUF_INIT; - while (fgets(author, sizeof(author), stdin) != NULL) { - if (!(author[0] == 'A' || author[0] == 'a') || - !starts_with(author + 1, "uthor: ")) - while (strbuf_getline(&author, stdin, '\n') != EOF) { ++ while (strbuf_getline_lf(&author, stdin) != EOF) { + const char *v; + if (!skip_prefix(author.buf, "Author: ", &v) && + !skip_prefix(author.buf, "author ", &v)) continue; - while (fgets(oneline, sizeof(oneline), stdin) && - oneline[0] != '\n') - while (strbuf_getline(&oneline, stdin, '\n') != EOF && ++ while (strbuf_getline_lf(&oneline, stdin) != EOF && + oneline.len) ; /* discard headers */ - while (fgets(oneline, sizeof(oneline), stdin) && - oneline[0] == '\n') - while (strbuf_getline(&oneline, stdin, '\n') != EOF && ++ while (strbuf_getline_lf(&oneline, stdin) != EOF && + !oneline.len) ; /* discard blanks */ - insert_one_record(log, author + 8, oneline); + insert_one_record(log, v, oneline.buf); } + strbuf_release(&author); + strbuf_release(&oneline); } void shortlog_add_commit(struct shortlog *log, struct commit *commit)