Skip to content

Commit 78c20b8

Browse files
committed
Merge branch 'ma/shortlog-revparse'
"git shortlog cruft" aborted with a BUG message when run outside a Git repository. The command has been taught to complain about extra and unwanted arguments on its command line instead in such a case. * ma/shortlog-revparse: shortlog: disallow left-over arguments outside repo shortlog: add usage-string for stdin-reading git-shortlog.txt: reorder usages
2 parents a26e1f4 + 4aa0161 commit 78c20b8

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Documentation/git-shortlog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ git-shortlog - Summarize 'git log' output
88
SYNOPSIS
99
--------
1010
[verse]
11-
git log --pretty=short | 'git shortlog' [<options>]
1211
'git shortlog' [<options>] [<revision range>] [[\--] <path>...]
12+
git log --pretty=short | 'git shortlog' [<options>]
1313

1414
DESCRIPTION
1515
-----------

builtin/shortlog.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#include "parse-options.h"
1212

1313
static char const * const shortlog_usage[] = {
14-
N_("git shortlog [<options>] [<revision-range>] [[--] [<path>...]]"),
14+
N_("git shortlog [<options>] [<revision-range>] [[--] <path>...]"),
15+
N_("git log --pretty=short | git shortlog [<options>]"),
1516
NULL
1617
};
1718

@@ -292,6 +293,11 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
292293
parse_done:
293294
argc = parse_options_end(&ctx);
294295

296+
if (nongit && argc > 1) {
297+
error(_("too many arguments given outside repository"));
298+
usage_with_options(shortlog_usage, options);
299+
}
300+
295301
if (setup_revisions(argc, argv, &rev, NULL) != 1) {
296302
error(_("unrecognized argument: %s"), argv[1]);
297303
usage_with_options(shortlog_usage, options);

t/t4201-shortlog.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ test_expect_success !MINGW 'shortlog can read --format=raw output' '
127127
test_cmp expect out
128128
'
129129

130+
test_expect_success 'shortlog from non-git directory refuses extra arguments' '
131+
test_must_fail env GIT_DIR=non-existing git shortlog foo 2>out &&
132+
test_i18ngrep "too many arguments" out
133+
'
134+
130135
test_expect_success 'shortlog should add newline when input line matches wraplen' '
131136
cat >expect <<\EOF &&
132137
A U Thor (2):

0 commit comments

Comments
 (0)