{"thread":{"id":"65351","subject":"[PATCH v4 1/2] repo: factor repo usage strings into shared macros","startedAt":"2026-03-25T11:52:14Z","lastAt":"2026-03-26T14:08:06Z","messageCount":5,"participants":["Mahi Kassa","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":4,"patchTotal":2},"messages":[{"id":"539932","messageId":"20260325115148.101867-1-mahlet.takassa@gmail.com","threadId":"65351","inReplyTo":null,"subject":"[PATCH v4 1/2] repo: factor repo usage strings into shared macros","fromName":"Mahi Kassa","fromEmail":"mahlet.takassa@gmail.com","sentAt":"2026-03-25T11:51:47Z","receivedAt":"2026-03-25T11:52:14Z","isPatch":true,"sender":{"key":"mahlet.takassa@gmail.com","avatar":null},"body":"Factor the \"git repo info\" and \"git repo structure\" usage\nstrings into shared macros so they can be reused in multiple\nusage arrays.\n\nThis is a preparatory refactoring for subsequent changes to\nsubcommand-specific help output.\n\nSigned-off-by: Mahi Kassa <mahlet.takassa@gmail.com>\n\n---\nv4:\n- split the preparatory macro refactoring into its own patch\n builtin/repo.c | 14 ++++++++++----\n 1 file changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 55f9b9095c..b5146499d0 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -20,11 +20,17 @@\n #include \"tree-walk.h\"\n #include \"utf8.h\"\n \n+#define REPO_INFO_USAGE \\\n+\t\"git repo info [--format=(lines|nul) | -z] [--all | <key>...]\", \\\n+\t\"git repo info --keys [--format=(lines|nul) | -z]\"\n+\n+#define REPO_STRUCTURE_USAGE \\\n+\t\"git repo structure [--format=(table|lines|nul) | -z]\"\n+\n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(lines|nul) | -z] [--all | <key>...]\",\n-\t\"git repo info --keys [--format=(lines|nul) | -z]\",\n-\t\"git repo structure [--format=(table|lines|nul) | -z]\",\n-\tNULL\n+\tREPO_INFO_USAGE,\n+\tREPO_STRUCTURE_USAGE,\n+\tNULL,\n };\n \n typedef int get_value_fn(struct repository *repo, struct strbuf *buf);\n-- \n2.34.1\n\n"},{"id":"539933","messageId":"20260325115148.101867-2-mahlet.takassa@gmail.com","threadId":"65351","inReplyTo":"20260325115148.101867-1-mahlet.takassa@gmail.com","subject":"[PATCH v4 2/2] repo: show subcommand-specific help text","fromName":"Mahi Kassa","fromEmail":"mahlet.takassa@gmail.com","sentAt":"2026-03-25T11:51:48Z","receivedAt":"2026-03-25T11:52:19Z","isPatch":true,"sender":{"key":"mahlet.takassa@gmail.com","avatar":null},"body":"Use subcommand-specific usage arrays for \"git repo info\" and\n\"git repo structure\" so that each command shows only its own\nsynopsis in help output.\n\nAdd tests to cover the subcommand help behavior.\n\nSigned-off-by: Mahi Kassa <mahlet.takassa@gmail.com>\n\n---\nv4:\n- split the subcommand-specific help change into a second patch\n- keep the behavior change and tests together\n builtin/repo.c            | 14 ++++++++++++--\n t/t1900-repo-info.sh      |  6 ++++++\n t/t1901-repo-structure.sh |  6 ++++++\n 3 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex b5146499d0..71a5c1c29c 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -33,6 +33,16 @@ static const char *const repo_usage[] = {\n \tNULL,\n };\n \n+static const char *const repo_info_usage[] = {\n+\tREPO_INFO_USAGE,\n+\tNULL,\n+};\n+\n+static const char *const repo_structure_usage[] = {\n+\tREPO_STRUCTURE_USAGE,\n+\tNULL,\n+};\n+\n typedef int get_value_fn(struct repository *repo, struct strbuf *buf);\n \n enum output_format {\n@@ -220,7 +230,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n \t\tOPT_END()\n \t};\n \n-\targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n+\targc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);\n \n \tif (show_keys && (all_keys || argc))\n \t\tdie(_(\"--keys cannot be used with a <key> or --all\"));\n@@ -885,7 +895,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,\n \t\tOPT_END()\n \t};\n \n-\targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n+\targc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);\n \tif (argc)\n \t\tusage(_(\"too many arguments\"));\n \ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex a9eb07abe8..39bb77dda0 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -149,4 +149,10 @@ test_expect_success 'git repo info --keys uses lines as its default output forma\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'git repo info -h shows only repo info usage' '\n+\ttest_must_fail git repo info -h >actual &&\n+\ttest_grep \"git repo info\" actual &&\n+\ttest_grep ! \"git repo structure\" actual\n+'\n+\n test_done\ndiff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\nindex 98921ce1cb..10050abd70 100755\n--- a/t/t1901-repo-structure.sh\n+++ b/t/t1901-repo-structure.sh\n@@ -224,4 +224,10 @@ test_expect_success 'progress meter option' '\n \t)\n '\n \n+test_expect_success 'git repo structure -h shows only repo structure usage' '\n+\ttest_must_fail git repo structure -h >actual &&\n+\ttest_grep \"git repo structure\" actual &&\n+\ttest_grep ! \"git repo info\" actual\n+'\n+\n test_done\n-- \n2.34.1\n\n"},{"id":"539967","messageId":"xmqqqzp7vmlm.fsf@gitster.g","threadId":"65351","inReplyTo":"20260325115148.101867-1-mahlet.takassa@gmail.com","subject":"Re: [PATCH v4 1/2] repo: factor repo usage strings into shared macros","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-25T17:35:17Z","receivedAt":"2026-03-25T17:35:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":null},"body":"Mahi Kassa <mahlet.takassa@gmail.com> writes:\n\n> Factor the \"git repo info\" and \"git repo structure\" usage\n> strings into shared macros so they can be reused in multiple\n> usage arrays.\n>\n> This is a preparatory refactoring for subsequent changes to\n> subcommand-specific help output.\n>\n> Signed-off-by: Mahi Kassa <mahlet.takassa@gmail.com>\n>\n> ---\n> v4:\n> - split the preparatory macro refactoring into its own patch\n>  builtin/repo.c | 14 ++++++++++----\n>  1 file changed, 10 insertions(+), 4 deletions(-)\n\nLooking good.  The distribution of commas are sensible, too.\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 55f9b9095c..b5146499d0 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -20,11 +20,17 @@\n>  #include \"tree-walk.h\"\n>  #include \"utf8.h\"\n>  \n> +#define REPO_INFO_USAGE \\\n> +\t\"git repo info [--format=(lines|nul) | -z] [--all | <key>...]\", \\\n> +\t\"git repo info --keys [--format=(lines|nul) | -z]\"\n> +\n> +#define REPO_STRUCTURE_USAGE \\\n> +\t\"git repo structure [--format=(table|lines|nul) | -z]\"\n> +\n>  static const char *const repo_usage[] = {\n> -\t\"git repo info [--format=(lines|nul) | -z] [--all | <key>...]\",\n> -\t\"git repo info --keys [--format=(lines|nul) | -z]\",\n> -\t\"git repo structure [--format=(table|lines|nul) | -z]\",\n> -\tNULL\n> +\tREPO_INFO_USAGE,\n> +\tREPO_STRUCTURE_USAGE,\n> +\tNULL,\n>  };\n>  \n>  typedef int get_value_fn(struct repository *repo, struct strbuf *buf);\n"},{"id":"539968","messageId":"xmqqldffvmd5.fsf@gitster.g","threadId":"65351","inReplyTo":"20260325115148.101867-2-mahlet.takassa@gmail.com","subject":"Re: [PATCH v4 2/2] repo: show subcommand-specific help text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-25T17:40:22Z","receivedAt":"2026-03-25T17:40:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":null},"body":"Mahi Kassa <mahlet.takassa@gmail.com> writes:\n\n> Use subcommand-specific usage arrays for \"git repo info\" and\n> \"git repo structure\" so that each command shows only its own\n> synopsis in help output.\n>\n> Add tests to cover the subcommand help behavior.\n>\n> Signed-off-by: Mahi Kassa <mahlet.takassa@gmail.com>\n>\n> ---\n> v4:\n> - split the subcommand-specific help change into a second patch\n> - keep the behavior change and tests together\n>  builtin/repo.c            | 14 ++++++++++++--\n>  t/t1900-repo-info.sh      |  6 ++++++\n>  t/t1901-repo-structure.sh |  6 ++++++\n>  3 files changed, 24 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index b5146499d0..71a5c1c29c 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -33,6 +33,16 @@ static const char *const repo_usage[] = {\n>  \tNULL,\n>  };\n>  \n> +static const char *const repo_info_usage[] = {\n> +\tREPO_INFO_USAGE,\n> +\tNULL,\n> +};\n> +\n> +static const char *const repo_structure_usage[] = {\n> +\tREPO_STRUCTURE_USAGE,\n> +\tNULL,\n> +};\n> +\n>  typedef int get_value_fn(struct repository *repo, struct strbuf *buf);\n>  \n>  enum output_format {\n> @@ -220,7 +230,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n>  \t\tOPT_END()\n>  \t};\n>  \n> -\targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n> +\targc = parse_options(argc, argv, prefix, options, repo_info_usage, 0);\n>  \n>  \tif (show_keys && (all_keys || argc))\n>  \t\tdie(_(\"--keys cannot be used with a <key> or --all\"));\n> @@ -885,7 +895,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,\n>  \t\tOPT_END()\n>  \t};\n>  \n> -\targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n> +\targc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);\n>  \tif (argc)\n>  \t\tusage(_(\"too many arguments\"));\n\nOK.  It makes sense.  Is repo_usage() still used?\n\n    ... goes and looks ...\n\nYes, \"git repo -h\" uses it to tell us that info/structure are the\navailable subcommands.\n\n> diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\n> index a9eb07abe8..39bb77dda0 100755\n> --- a/t/t1900-repo-info.sh\n> +++ b/t/t1900-repo-info.sh\n> @@ -149,4 +149,10 @@ test_expect_success 'git repo info --keys uses lines as its default output forma\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success 'git repo info -h shows only repo info usage' '\n> +\ttest_must_fail git repo info -h >actual &&\n\nThere was a topic about the exit code and the output destination of\n\"-h\", which is the mode of any command that gives exactly what the\nend-user asked, which should go to the standard error, and does so\nsuccessfully, which hints that we may want to exit with 0.  So this\nmay later have to change to expect success, but let's leave it as is\nfor now.  Existing tests on \"-h\" will also have to be updatd if/when\nsuch a change happens.\n\n> +\ttest_grep \"git repo info\" actual &&\n> +\ttest_grep ! \"git repo structure\" actual\n> +'\n>  test_done\n> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\n> index 98921ce1cb..10050abd70 100755\n> --- a/t/t1901-repo-structure.sh\n> +++ b/t/t1901-repo-structure.sh\n> @@ -224,4 +224,10 @@ test_expect_success 'progress meter option' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'git repo structure -h shows only repo structure usage' '\n> +\ttest_must_fail git repo structure -h >actual &&\n> +\ttest_grep \"git repo structure\" actual &&\n> +\ttest_grep ! \"git repo info\" actual\n> +'\n> +\n>  test_done\n\nLooking good.\n\nWill queue.  Thanks.\n"},{"id":"540076","messageId":"acU9vzLUPx4tlmcD@pks.im","threadId":"65351","inReplyTo":"xmqqldffvmd5.fsf@gitster.g","subject":"Re: [PATCH v4 2/2] repo: show subcommand-specific help text","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-26T14:07:59Z","receivedAt":"2026-03-26T14:08:06Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":null},"body":"On Wed, Mar 25, 2026 at 10:40:22AM -0700, Junio C Hamano wrote:\n> Looking good.\n> \n> Will queue.  Thanks.\n\nYup, I'm happy with this version, too. Thanks!\n\nPatrick\n"}]}