public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] repo: show subcommand-specific help text
@ 2026-03-23 15:29 Mahi Kassa
  2026-03-23 19:32 ` Derrick Stolee
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mahi Kassa @ 2026-03-23 15:29 UTC (permalink / raw)
  To: git; +Cc: gitster, lucasseikioshiro, jltobler

Use subcommand-specific usage arrays for "git repo info" and "git repo structure" so that each command shows only its own synopsis in help output.

Keep the top-level "git repo -h" output unchanged, and add tests to cover the subcommand help behavior.
---
 builtin/repo.c            | 15 +++++++++++++--
 t/t1900-repo-info.sh      |  6 +++++-
 t/t1901-repo-structure.sh |  5 +++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/builtin/repo.c b/builtin/repo.c
index 55f9b9095c..5ccc5c401a 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -27,6 +27,17 @@ static const char *const repo_usage[] = {
 	NULL
 };
 
+static const char *const repo_info_usage[] = {
+	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
+	"git repo info --keys [--format=(lines|nul) | -z]",
+	NULL
+};
+
+static const char *const repo_structure_usage[] = {
+	"git repo structure [--format=(table|lines|nul) | -z]",
+	NULL
+};
+
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
@@ -214,7 +225,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 		OPT_END()
 	};
 
-	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);
 
 	if (show_keys && (all_keys || argc))
 		die(_("--keys cannot be used with a <key> or --all"));
@@ -879,7 +890,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 		OPT_END()
 	};
 
-	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);
 	if (argc)
 		usage(_("too many arguments"));
 
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index a9eb07abe8..e0e79ff167 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -148,5 +148,9 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
 	git repo info --keys >actual &&
 	test_cmp expect actual
 '
-
+test_expect_success 'git repo info -h shows only repo info usage' '
+	test_must_fail git repo info -h >actual &&
+	test_grep "git repo info" actual &&
+	test_grep ! "git repo structure" actual
+'
 test_done
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 98921ce1cb..0f7ec4da10 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -224,4 +224,9 @@ test_expect_success 'progress meter option' '
 	)
 '
 
+test_expect_success 'git repo structure -h shows only repo structure usage' '
+	test_must_fail git repo structure -h >actual &&
+	test_grep "git repo structure" actual &&
+	test_grep ! "git repo info" actual
+'
 test_done
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-03-25 16:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 15:29 [PATCH] repo: show subcommand-specific help text Mahi Kassa
2026-03-23 19:32 ` Derrick Stolee
2026-03-24  6:26 ` Patrick Steinhardt
2026-03-24 12:21 ` [PATCH v2] " Mahi Kassa
2026-03-24 12:52   ` Patrick Steinhardt
2026-03-24 17:07   ` Derrick Stolee
2026-03-24 18:48 ` [PATCH v3] " Mahi Kassa
2026-03-24 19:15   ` Derrick Stolee
2026-03-25 10:01   ` Patrick Steinhardt
2026-03-25 16:55     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox