]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-shortlog.c
Merge branch 'rs/archive'
[git.git] / builtin-shortlog.c
index 9107bffb9b004407abb5174142c99ce7d1c5e864..f8bcbfce4009337c4aea0b923a620fc4697e4df3 100644 (file)
@@ -154,6 +154,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
        if (!author)
                die("Missing author: %s",
                    sha1_to_hex(commit->object.sha1));
+       if (log->user_format) {
+               struct strbuf buf = STRBUF_INIT;
+
+               pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
+                       DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+               insert_one_record(log, author, buf.buf);
+               strbuf_release(&buf);
+               return;
+       }
        if (*buffer)
                buffer++;
        insert_one_record(log, author, !*buffer ? "<none>" : buffer);
@@ -255,21 +264,13 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
                            PARSE_OPT_KEEP_ARGV0);
 
        for (;;) {
-               int n;
                switch (parse_options_step(&ctx, options, shortlog_usage)) {
                case PARSE_OPT_HELP:
                        exit(129);
                case PARSE_OPT_DONE:
                        goto parse_done;
                }
-               n = handle_revision_opt(&rev, ctx.argc, ctx.argv,
-                                       &ctx.cpidx, ctx.out);
-               if (n <= 0) {
-                       error("unknown option `%s'", ctx.argv[0]);
-                       usage_with_options(shortlog_usage, options);
-               }
-               ctx.argv += n;
-               ctx.argc -= n;
+               parse_revision_opt(&rev, &ctx, options, shortlog_usage);
        }
 parse_done:
        argc = parse_options_end(&ctx);
@@ -279,6 +280,8 @@ parse_done:
                usage_with_options(shortlog_usage, options);
        }
 
+       log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
+
        /* assume HEAD if from a tty */
        if (!nongit && !rev.pending.nr && isatty(0))
                add_head_to_pending(&rev);