X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-shortlog.c;h=29343aefc843c4dd22095f559262bc6b5e381440;hb=40250af411f33afa0c39a5d461829b676453ce3b;hp=3fc43dd7dd89fea2fb7f02e694ed632215002e13;hpb=8042ed1cebd37419ff38f540482355c0f1d30936;p=git.git diff --git a/builtin-shortlog.c b/builtin-shortlog.c index 3fc43dd7d..29343aefc 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -4,7 +4,6 @@ #include "diff.h" #include "path-list.h" #include "revision.h" -#include static const char shortlog_usage[] = "git-shortlog [-n] [-s] [... ]"; @@ -125,7 +124,7 @@ static void insert_author_oneline(struct path_list *list, else free(buffer); - if (!strncmp(oneline, "[PATCH", 6)) { + if (!prefixcmp(oneline, "[PATCH")) { char *eob = strchr(oneline, ']'); if (eob) { @@ -180,7 +179,7 @@ static void read_from_stdin(struct path_list *list) while (fgets(buffer, sizeof(buffer), stdin) != NULL) { char *bob; if ((buffer[0] == 'A' || buffer[0] == 'a') && - !strncmp(buffer + 1, "uthor: ", 7) && + !prefixcmp(buffer + 1, "uthor: ") && (bob = strchr(buffer + 7, '<')) != NULL) { char buffer2[1024], offset = 0; @@ -218,20 +217,20 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list) prepare_revision_walk(rev); while ((commit = get_revision(rev)) != NULL) { - char *author = NULL, *oneline, *buffer; + const char *author = NULL, *oneline, *buffer; int authorlen = authorlen, onelinelen; /* get author and oneline */ for (buffer = commit->buffer; buffer && *buffer != '\0' && *buffer != '\n'; ) { - char *eol = strchr(buffer, '\n'); + const char *eol = strchr(buffer, '\n'); if (eol == NULL) eol = buffer + strlen(buffer); else eol++; - if (!strncmp(buffer, "author ", 7)) { + if (!prefixcmp(buffer, "author ")) { char *bracket = strchr(buffer, '<'); if (bracket == NULL || bracket > eol) @@ -305,8 +304,11 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) if (!access(".mailmap", R_OK)) read_mailmap(".mailmap"); - if (rev.pending.nr == 0) + if (rev.pending.nr == 0) { + if (isatty(0)) + fprintf(stderr, "(reading log to summarize from standard input)\n"); read_from_stdin(&list); + } else get_from_rev(&rev, &list);