git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] repo: show subcommand-specific help text

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 24, 2026, 06:26 UTC
Message-ID
<acIujxB3kod2VYfB@pks.im>
In-Reply-To
<20260323152937.257406-1-mahlet.takassa@gmail.com>
On Mon, Mar 23, 2026 at 04:29:37PM +0100, Mahi Kassa wrote:
Show 22 quoted lines
> 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 {

These are basically the split-out parts of `repo_usage`, which makes sense. But it also means that it will be quite easy for those two usages to diverge over time. Would it make sense to maybe split the individual usage strings into macros that we can reuse? Something like the below (partial) patch.

Thanks!
Patrick
diff --git a/builtin/repo.c b/builtin/repo.c
index 55f9b9095c..200c5901a7 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -20,11 +20,22 @@
 #include "tree-walk.h"
 #include "utf8.h"
 
+#define REPO_INFO_USAGE \
+	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \
+	"git repo info --keys [--format=(lines|nul) | -z]"
+
+#define REPO_STRUCTURE_USAGE \
+	"git repo structure [--format=(table|lines|nul) | -z]"
+
 static const char *const repo_usage[] = {
-	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
-	"git repo info --keys [--format=(lines|nul) | -z]",
-	"git repo structure [--format=(table|lines|nul) | -z]",
-	NULL
+	REPO_INFO_USAGE,
+	REPO_STRUCTURE_USAGE,
+	NULL,
+};
+
+static const char *const repo_info_usage[] = {
+	REPO_INFO_USAGE,
+	NULL,
 };
 
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
@@ -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"));
Previous: Derrick StoleeNext: Mahi Kassa
Message 3 of 10 in “repo: show subcommand-specific help text”
  1. repo: show subcommand-specific help textMahi Kassa, Mar 23, 2026
  2. Derrick StoleeMar 23, 2026
  3. Patrick SteinhardtMar 24, 2026
  4. repo: show subcommand-specific help textMahi Kassa, Mar 24, 2026
  5. Patrick SteinhardtMar 24, 2026
  6. Derrick StoleeMar 24, 2026
  7. repo: show subcommand-specific help textMahi Kassa, Mar 24, 2026
  8. Derrick StoleeMar 24, 2026
  9. Patrick SteinhardtMar 25, 2026
  10. Junio C HamanoMar 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.