builtin/apply: make build_fake_ancestor() return -1 on error
[gitweb.git] / builtin / shortlog.c
index 39d74fe23bb8d29fd58a78109aa49d8add0ae8f9..25fa8a6aed72bb91c3b99121059a90cc976976a5 100644 (file)
@@ -229,16 +229,15 @@ void shortlog_init(struct shortlog *log)
        log->wrap = DEFAULT_WRAPLEN;
        log->in1 = DEFAULT_INDENT1;
        log->in2 = DEFAULT_INDENT2;
-       log->file = stdout;
 }
 
 int cmd_shortlog(int argc, const char **argv, const char *prefix)
 {
-       static struct shortlog log;
-       static struct rev_info rev;
+       struct shortlog log = { STRING_LIST_INIT_NODUP };
+       struct rev_info rev;
        int nongit = !startup_info->have_repository;
 
-       static const struct option options[] = {
+       const struct option options[] = {
                OPT_BOOL('n', "numbered", &log.sort_by_number,
                         N_("sort output according to the number of commits per author")),
                OPT_BOOL('s', "summary", &log.summary,
@@ -277,6 +276,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 
        log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
        log.abbrev = rev.abbrev;
+       log.file = rev.diffopt.file;
 
        /* assume HEAD if from a tty */
        if (!nongit && !rev.pending.nr && isatty(0))
@@ -290,6 +290,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
                get_from_rev(&rev, &log);
 
        shortlog_output(&log);
+       if (log.file != stdout)
+               fclose(log.file);
        return 0;
 }