From 681c0a247bb6ec38ec9ac9ed745e2ef2c91f447d Mon Sep 17 00:00:00 2001 From: Emily Shaffer Date: Thu, 26 Oct 2023 11:22:31 -0700 Subject: bugreport: reject positional arguments git-bugreport already rejected unrecognized flag arguments, like `--diaggnose`, but this doesn't help if the user's mistake was to forget the `--` in front of the argument. This can result in a user's intended argument not being parsed with no indication to the user that something went wrong. Since git-bugreport presently doesn't take any positionals at all, let's reject all positionals and give the user a usage hint. Signed-off-by: Emily Shaffer Signed-off-by: Junio C Hamano --- builtin/bugreport.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtin') diff --git a/builtin/bugreport.c b/builtin/bugreport.c index d2ae5c305d..3106e56a13 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -126,6 +126,11 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, bugreport_options, bugreport_usage, 0); + if (argc) { + error(_("unknown argument `%s'"), argv[0]); + usage(bugreport_usage[0]); + } + /* Prepare the path to put the result */ prefixed_filename = prefix_filename(prefix, option_output ? option_output : ""); -- cgit v1.3-5-g9baa