[PATCH v2 0/6] shortlog fixes and optimizations
From: Jeff King <hidden>
Date: 2016-06-15 23:07:48
Subsystem:
the rest · Maintainer:
Linus Torvalds
On Mon, Jan 18, 2016 at 11:55:18AM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:quoted
So it's not wrong, but it's perhaps more complicated than it needs to be. We could scrap this patch in favor of just: if (!skip_prefix(author, "Author: ", &v) && !skip_prefix(author, "author ", &v)) continue; That is technically more strict (it does not take "author: ", which is accepted by the current code), but matches "git log" and "git log --raw" output, and misses nothing that git has ever generated. And it extends naturally to: if (!skip_prefix(author, "Commit: ", &v) && !skip_prefix(author, "committer ", &v)) continue;Yeah, I agree that the above long-hand would be more readable.
OK. Here it is again (the whole series, since the change creates minor conflicts some of the later patches). The interdiff is:
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 3a0c863..adbf1fd 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c@@ -113,27 +113,6 @@ static void insert_one_record(struct shortlog *log, } } -/* - * If header is "author", match candidate against the regex /[Aa]uthor:? /, - * and return a pointer to the remainder of the string in out_value. - */ -static int match_ident_header(const char *candidate, const char *header, - const char **out_value) -{ - const char *v; - - if (tolower(*candidate++) != tolower(*header++)) - return 0; - if (!skip_prefix(candidate, header, &v)) - return 0; - if (*v == ':') - v++; - if (*v++ != ' ') - return 0; - *out_value = v; - return 1; -} - static void read_from_stdin(struct shortlog *log) { struct strbuf author = STRBUF_INIT;
@@ -141,7 +120,8 @@ static void read_from_stdin(struct shortlog *log) while (strbuf_getline(&author, stdin, '\n') != EOF) { const char *v; - if (!match_ident_header(author.buf, "author", &v)) + if (!skip_prefix(author.buf, "Author: ", &v) && + !skip_prefix(author.buf, "author ", &v)) continue; while (strbuf_getline(&oneline, stdin, '\n') != EOF && oneline.len)