public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Mahi Kassa <mahlet.takassa@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, lucasseikioshiro@gmail.com,
	jltobler@gmail.com, stolee@gmail.com,
	Mahi Kassa <mahlet.takassa@gmail.com>
Subject: [PATCH v4 2/2] repo: show subcommand-specific help text
Date: Wed, 25 Mar 2026 12:51:48 +0100	[thread overview]
Message-ID: <20260325115148.101867-2-mahlet.takassa@gmail.com> (raw)
In-Reply-To: <20260325115148.101867-1-mahlet.takassa@gmail.com>

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.

Add tests to cover the subcommand help behavior.

Signed-off-by: Mahi Kassa <mahlet.takassa@gmail.com>

---
v4:
- split the subcommand-specific help change into a second patch
- keep the behavior change and tests together
 builtin/repo.c            | 14 ++++++++++++--
 t/t1900-repo-info.sh      |  6 ++++++
 t/t1901-repo-structure.sh |  6 ++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/builtin/repo.c b/builtin/repo.c
index b5146499d0..71a5c1c29c 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -33,6 +33,16 @@ static const char *const repo_usage[] = {
 	NULL,
 };
 
+static const char *const repo_info_usage[] = {
+	REPO_INFO_USAGE,
+	NULL,
+};
+
+static const char *const repo_structure_usage[] = {
+	REPO_STRUCTURE_USAGE,
+	NULL,
+};
+
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
@@ -220,7 +230,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"));
@@ -885,7 +895,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..39bb77dda0 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -149,4 +149,10 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
 	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..10050abd70 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -224,4 +224,10 @@ 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


  reply	other threads:[~2026-03-25 11:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260323152937.257406-1- mahlet.takassa@gmail.com>
2026-03-25 11:51 ` [PATCH v4 1/2] repo: factor repo usage strings into shared macros Mahi Kassa
2026-03-25 11:51   ` Mahi Kassa [this message]
2026-03-25 17:40     ` [PATCH v4 2/2] repo: show subcommand-specific help text Junio C Hamano
2026-03-26 14:07       ` Patrick Steinhardt
2026-03-25 17:35   ` [PATCH v4 1/2] repo: factor repo usage strings into shared macros Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260325115148.101867-2-mahlet.takassa@gmail.com \
    --to=mahlet.takassa@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=lucasseikioshiro@gmail.com \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox