]> git.ipfire.org Git - thirdparty/git.git/commitdiff
help: correct logic error in combining --all and --guides
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 21 Sep 2021 22:40:35 +0000 (00:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Sep 2021 17:30:43 +0000 (10:30 -0700)
The --all and --guides commands could be combined, which wouldn't have
any impact on the output except for:

    git help --all --guides --no-verbose

Listing the guide alongside that output was clearly not intended, so
let's error out here. See 002b726a400 (builtin/help.c: add
list_common_guides_help() function, 2013-04-02) for the initial
implementation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/help.c
t/t0012-help.sh

index d0c9605dbb5d0b03a6b102f31208b0507576614f..30f160a46691ec76476e79f541b4d575e7a05172 100644 (file)
@@ -559,6 +559,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)
                usage_msg_opt(_("--config and --all cannot be combined"),
                              builtin_help_usage, builtin_help_options);
 
+       if (show_all && show_guides)
+               usage_msg_opt(_("--config and --guides cannot be combined"),
+                             builtin_help_usage, builtin_help_options);
+
        if (show_config && show_guides)
                usage_msg_opt(_("--config and --guides cannot be combined"),
                              builtin_help_usage, builtin_help_options);
index b4ed6229ed89c563fef7228d39cd113584a13d34..69e385d3b662c226b841deda2b221a8f3bae2473 100755 (executable)
@@ -36,7 +36,12 @@ test_expect_success 'basic help commands' '
 
 test_expect_success 'invalid usage' '
        test_expect_code 129 git help -g add &&
-       test_expect_code 129 git help -a -c
+       test_expect_code 129 git help -a -c &&
+
+       test_expect_code 129 git help -g add &&
+       test_expect_code 129 git help -a -g &&
+
+       test_expect_code 129 git help -g -c
 '
 
 test_expect_success "works for commands and guides by default" '