Code

shortlog: do not require to run from inside a git repository
[git.git] / builtin-shortlog.c
index b22b0edd65eefacabb648962b9c20c695609a3f5..bd795b1db7a4054a0218d1ec96794ad25d656896 100644 (file)
@@ -229,7 +229,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 {
        struct shortlog log;
        struct rev_info rev;
+       int nongit;
 
+       prefix = setup_git_directory_gently(&nongit);
        shortlog_init(&log);
 
        /* since -n is a shadowed rev argument, parse our args first */
@@ -259,7 +261,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
                die ("unrecognized argument: %s", argv[1]);
 
        /* assume HEAD if from a tty */
-       if (!rev.pending.nr && isatty(0))
+       if (!nongit && !rev.pending.nr && isatty(0))
                add_head_to_pending(&rev);
        if (rev.pending.nr == 0) {
                read_from_stdin(&log);