diff --git a/revision.c b/revision.c index 1c9934fb4d..9348820657 100644 --- a/revision.c +++ b/revision.c @@ -2738,7 +2738,7 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx, /* handle_revision_opt() has already reported the error. */ usage_with_options(usagestr, options); } else if (!n) { - error("unknown option `%s'", ctx->argv[0]); + error("unknown option `%s'", ctx->out[ctx->cpidx - 1]); usage_with_options(usagestr, options); } ctx->argv += n; diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index cde519402e..99825e91d7 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -440,4 +440,9 @@ test_expect_success 'invalid revision options are not reported as unknown' ' test_grep ! "unknown option" err ' +test_expect_success 'unknown revision options are reported correctly' ' + test_must_fail git shortlog -n --no-such-option 2>err && + test_grep "unknown option .*--no-such-option" err +' + test_done