Skip to content

Commit 373bfa6

Browse files
pks-tgitster
authored andcommitted
builtin/shortlog: don't set up revisions without repo
It is possible to run git-shortlog(1) outside of a repository by passing it output from git-log(1) via standard input. Obviously, as there is no repository in that context, it is thus unsupported to pass any revisions as arguments. Regardless of that we still end up calling `setup_revisions()`. While that works alright, it is somewhat strange. Furthermore, this is about to cause problems when we unset the default object hash. Refactor the code to only call `setup_revisions()` when we have a repository. This is safe to do as we already verify that there are no arguments when running outside of a repository anyway. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab27490 commit 373bfa6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/shortlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
435435
usage_with_options(shortlog_usage, options);
436436
}
437437

438-
if (setup_revisions(argc, argv, &rev, NULL) != 1) {
438+
if (!nongit && setup_revisions(argc, argv, &rev, NULL) != 1) {
439439
error(_("unrecognized argument: %s"), argv[1]);
440440
usage_with_options(shortlog_usage, options);
441441
}

0 commit comments

Comments
 (0)