Thread (40 messages) 40 messages, 4 authors, 2021-09-23

[PATCH v3 5/9] help: correct logic error in combining --all and --guides

flat view
STALE1858d

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-09-21 22:40:53
Subsystem: the rest · Maintainer: Linus Torvalds

Revision v3 (3 revisions archived).

Revisions (3)
  1. v1
  2. v2 [diff against previous]
  3. v3 current [diff against previous]
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 <redacted>
---
 builtin/help.c  | 4 ++++
 t/t0012-help.sh | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/builtin/help.c b/builtin/help.c
index d0c9605dbb5..30f160a4669 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -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);
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index b4ed6229ed8..69e385d3b66 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -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" '
-- 
2.33.0.1098.gf02a64c1a2d
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help