From: Derrick Stolee Date: Mon, 23 Mar 2026 19:32:44 GMT Subject: Re: [PATCH] repo: show subcommand-specific help text Message-ID: In-Reply-To: <20260323152937.257406-1-mahlet.takassa@gmail.com> On 3/23/2026 11:29 AM, Mahi Kassa wrote: > 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. Please wrap your lines in the commit message. > +static const char *const repo_info_usage[] = { > + "git repo info [--format=(lines|nul) | -z] [--all | ...]", > + "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 > +}; > + I did a visual comparison to the synopsis in Documentation/git-repo.adoc [1] and these look the same. (I suspect that they also exist in the repo_usage struct outside of the patch context, so they were easy to copy from there.) [1] https://github.com/git/git/blob/6e8d538aab8fe4dd07ba9fb87b5c7edcfa5706ad/Documentation/git-repo.adoc?plain=1#L10-L13 > - argc = parse_options(argc, argv, prefix, options, repo_usage, 0); > + argc = parse_options(argc, argv, prefix, options, repo_info_usage, 0); > - argc = parse_options(argc, argv, prefix, options, repo_usage, 0); > + argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0); Nice and easy here. > --- 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 > ' > - Don't erase the whitespace between tests. > +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 and keep whitespace between the end of the test and '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' ' You preserved the whitespace above this test. good. > + test_must_fail git repo structure -h >actual && > + test_grep "git repo structure" actual && > + test_grep ! "git repo info" actual > +' > test_done But here we need some before 'test_done'. Thanks, -Stolee