diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-11-07 04:26:44 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-11-07 04:26:44 +0300 |
commit | 840bd1c9ef6d287fa0fb93f11102eca988e875fa (patch) | |
tree | 38484dc1e90a90fa73171ad60d37981d96e227ee | |
parent | 9f7fbe07dc5069642c9494ebed4500e7b46e03b2 (diff) | |
parent | 681c0a247bb6ec38ec9ac9ed745e2ef2c91f447d (diff) |
Merge branch 'es/bugreport-no-extra-arg'
"git bugreport" learned to complain when it received a command line
argument that it will not use.
* es/bugreport-no-extra-arg:
bugreport: reject positional arguments
t0091-bugreport: stop using i18ngrep
-rw-r--r-- | builtin/bugreport.c | 5 | ||||
-rwxr-xr-x | t/t0091-bugreport.sh | 9 |
2 files changed, 13 insertions, 1 deletions
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 : ""); diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh index f6998269be..ae5b7dc31f 100755 --- a/t/t0091-bugreport.sh +++ b/t/t0091-bugreport.sh @@ -65,7 +65,14 @@ test_expect_success '--output-directory puts the report in the provided dir' ' test_expect_success 'incorrect arguments abort with usage' ' test_must_fail git bugreport --false 2>output && - test_i18ngrep usage output && + grep usage output && + test_path_is_missing git-bugreport-* +' + +test_expect_success 'incorrect positional arguments abort with usage and hint' ' + test_must_fail git bugreport false 2>output && + grep usage output && + grep false output && test_path_is_missing git-bugreport-* ' |