Message ID | 508e28ed1e21e9c646cec8473a65137d33f1df23.1713519789.git.ps@pks.im (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Stop relying on SHA1 fallback for `the_hash_algo` | expand |
On 24/04/19 11:51AM, Patrick Steinhardt wrote: > 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. > > Reghardless of that we still end up calling `setup_revisions()`. While s/Reghardless/Regardless/ > 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 <ps@pks.im> ...
diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 3c7cd2d6ef..d4daf31e22 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -435,7 +435,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix) usage_with_options(shortlog_usage, options); } - if (setup_revisions(argc, argv, &rev, NULL) != 1) { + if (!nongit && setup_revisions(argc, argv, &rev, NULL) != 1) { error(_("unrecognized argument: %s"), argv[1]); usage_with_options(shortlog_usage, options); }
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. Reghardless 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 <ps@pks.im> --- builtin/shortlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)