Because we must match both "Author" and "author" here, we
could not use skip_prefix, and had to hand-code a partial
case-insensitive match. Now that we have skip_prefix_case,
we can use it. This is technically more liberal in what it
matches (e.g., it will match AUTHOR), but in this particular
case that that's OK (we are matching git-log output, so we
expect arbitrary data like commit headers to be indented).

In addition to being easier to read, this will make the code
easier to adapt for matching other lines.

Signed-off-by: Jeff King <p...@peff.net>
---
To be honest, I'm not sure what the original was trying for. I assumed
it was to match "log --raw" output, but because we always expect the
colon, it doesn't. I think this may actually have broken in b8ec592
(Build in shortlog, 2006-10-22); the original perl script looked for:

  /^[Aa]uthor:?\s*/

We could re-fix that, I guess, but it seems clear that nobody actually
cares (and anybody sane uses the builtin traversal these days anyway).

We could similarly drop the case-insensitivity, as I don't think it is
helping anyone in practice (though that is less easy to know).

 builtin/shortlog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 35ebd17..86e277a 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -94,8 +94,8 @@ static void read_from_stdin(struct shortlog *log)
        char author[1024], oneline[1024];
 
        while (fgets(author, sizeof(author), stdin) != NULL) {
-               if (!(author[0] == 'A' || author[0] == 'a') ||
-                   !starts_with(author + 1, "uthor: "))
+               const char *v;
+               if (!skip_prefix_icase(author, "Author: ", &v))
                        continue;
                while (fgets(oneline, sizeof(oneline), stdin) &&
                       oneline[0] != '\n')
@@ -103,7 +103,7 @@ static void read_from_stdin(struct shortlog *log)
                while (fgets(oneline, sizeof(oneline), stdin) &&
                       oneline[0] == '\n')
                        ; /* discard blanks */
-               insert_one_record(log, author + 8, oneline);
+               insert_one_record(log, v, oneline);
        }
 }
 
-- 
2.7.0.rc3.367.g09631da

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to