Code

t3703: Skip tests using directory name ":" on Windows
[git.git] / builtin / shortlog.c
index 5089502800d5f477f47b6cd6499d278097f11e67..1a21e4b0538565f7a64488ed7b3a5c317e559699 100644 (file)
@@ -84,7 +84,7 @@ static void insert_one_record(struct shortlog *log,
                snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
        }
 
-       item = string_list_insert(namebuf, &log->list);
+       item = string_list_insert(&log->list, namebuf);
        if (item->util == NULL)
                item->util = xcalloc(1, sizeof(struct string_list));
 
@@ -115,7 +115,7 @@ static void insert_one_record(struct shortlog *log,
                }
        }
 
-       string_list_append(buffer, item->util);
+       string_list_append(item->util, buffer);
 }
 
 static void read_from_stdin(struct shortlog *log)
@@ -249,7 +249,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 {
        static struct shortlog log;
        static struct rev_info rev;
-       int nongit;
+       int nongit = !startup_info->have_repository;
 
        static const struct option options[] = {
                OPT_BOOLEAN('n', "numbered", &log.sort_by_number,
@@ -265,12 +265,11 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 
        struct parse_opt_ctx_t ctx;
 
-       prefix = setup_git_directory_gently(&nongit);
        git_config(git_default_config, NULL);
        shortlog_init(&log);
        init_revisions(&rev, prefix);
-       parse_options_start(&ctx, argc, argv, prefix, PARSE_OPT_KEEP_DASHDASH |
-                           PARSE_OPT_KEEP_ARGV0);
+       parse_options_start(&ctx, argc, argv, prefix, options,
+                           PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0);
 
        for (;;) {
                switch (parse_options_step(&ctx, options, shortlog_usage)) {