diff --git a/revision.c b/revision.c index cf5e6c1ec9..1c9934fb4d 100644 --- a/revision.c +++ b/revision.c @@ -2734,7 +2734,10 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx, { int n = handle_revision_opt(revs, ctx->argc, ctx->argv, &ctx->cpidx, ctx->out, NULL); - if (n <= 0) { + if (n < 0) { + /* handle_revision_opt() has already reported the error. */ + usage_with_options(usagestr, options); + } else if (!n) { error("unknown option `%s'", ctx->argv[0]); usage_with_options(usagestr, options); } diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 5f23fc147b..cde519402e 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -434,4 +434,10 @@ test_expect_success 'stdin with multiple groups reports error' ' test_must_fail git shortlog --group=author --group=committer err && + test_grep "bad --default argument" err && + test_grep ! "unknown option" err +' + test_done