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

[PATCH v4 0/2] repo: add --all to git-repo-info

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Nov 17, 2025, 15:02 UTC
Message-ID
<20251117151844.14802-1-lucasseikioshiro@gmail.com>
In-Reply-To
<20250915223618.13093-1-lucasseikioshiro@gmail.com>
Hi!

Sorry for only sending this after some weeks. I've been busy finishing my master's and I didn't have enough time to send another version. But here it is.

This fourth version of this patch addresses the issues pointed by Eric in the v3:

- I dropped the `strbuf quotebuf`, since it can be replaced by
  outputting `quote_c_style` directly to `stdout`;
- `print_field` now uses the string `value` instead of the
  `strbuf valbuf`;
- The variable `field` in `print_fields` was replaced by a pointer,
  since it didn't require to be copied;
- replace the help string by the suggested.
Lucas Seiki Oshiro (2):
  repo: factor out field printing to dedicated function
  repo: add --all to git-repo-info
 Documentation/git-repo.adoc |  6 ++--
 builtin/repo.c              | 62 +++++++++++++++++++++++++++----------
 t/t1900-repo.sh             | 21 +++++++++++++
 3 files changed, 69 insertions(+), 20 deletions(-)
Range-diff against v3:
1:  0db9aad2bc ! 1:  fce09770b8 repo: factor out field printing to dedicated function
    @@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)
      }
      
     +static void print_field(enum output_format format, const char *key,
    -+			struct strbuf *valbuf, struct strbuf *quotbuf)
    ++			const char *value)
     +{
    -+	strbuf_reset(quotbuf);
    -+
     +	switch (format) {
     +	case FORMAT_KEYVALUE:
    -+		quote_c_style(valbuf->buf, quotbuf, NULL, 0);
    -+		printf("%s=%s\n", key, quotbuf->buf);
    ++		printf("%s=", key);
    ++		quote_c_style(value, NULL, stdout, 0);
    ++		putchar('\n');
     +		break;
     +	case FORMAT_NUL_TERMINATED:
    -+		printf("%s\n%s%c", key, valbuf->buf, '\0');
    ++		printf("%s\n%s%c", key, value, '\0');
     +		break;
     +	default:
     +		BUG("not a valid output format: %d", format);
    @@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)
      static int print_fields(int argc, const char **argv,
      			struct repository *repo,
      			enum output_format format)
    + {
    + 	int ret = 0;
    + 	struct strbuf valbuf = STRBUF_INIT;
    +-	struct strbuf quotbuf = STRBUF_INIT;
    + 
    + 	for (int i = 0; i < argc; i++) {
    + 		get_value_fn *get_value;
     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
      		}
      
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
     -		default:
     -			BUG("not a valid output format: %d", format);
     -		}
    -+		print_field(format, key, &valbuf, &quotbuf);
    ++		print_field(format, key, valbuf.buf);
      	}
      
      	strbuf_release(&valbuf);
    +-	strbuf_release(&quotbuf);
    + 	return ret;
    + }
    + 
2:  b6ecdc2c2f ! 2:  ccdad86123 repo: add --all to git-repo-info
    @@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor
      [synopsis]
     -git repo info [--format=(keyvalue|nul)] [-z] [<key>...]
     +git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
    + git repo structure [--format=(table|keyvalue|nul)]
      
      DESCRIPTION
    - -----------
     @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
      
      COMMANDS
    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN
     
      ## builtin/repo.c ##
     @@
    - #include "shallow.h"
    + #include "utf8.h"
      
      static const char *const repo_usage[] = {
     -	"git repo info [--format=(keyvalue|nul)] [-z] [<key>...]",
     +	"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
    + 	"git repo structure [--format=(table|keyvalue|nul)]",
      	NULL
      };
    - 
     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
      	return ret;
      }
    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,
     +			     enum output_format format)
     +{
     +	struct strbuf valbuf = STRBUF_INIT;
    -+	struct strbuf quotbuf = STRBUF_INIT;
     +
     +	for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
    -+		struct field field = repo_info_fields[i];
    ++		const struct field *field = &repo_info_fields[i];
     +
     +		strbuf_reset(&valbuf);
    -+		field.get_value(repo, &valbuf);
    -+		print_field(format, field.key, &valbuf, &quotbuf);
    ++		field->get_value(repo, &valbuf);
    ++		print_field(format, field->key, valbuf.buf);
     +	}
     +
     +	strbuf_release(&valbuf);
    -+	strbuf_release(&quotbuf);
     +}
     +
      static int parse_format_cb(const struct option *opt,
      			   const char *arg, int unset UNUSED)
      {
    -@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,
    - 		     struct repository *repo)
    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
    + 			 struct repository *repo)
      {
      	enum output_format format = FORMAT_KEYVALUE;
     +	int all_keys = 0;
      	struct option options[] = {
      		OPT_CALLBACK_F(0, "format", &format, N_("format"),
      			       N_("output format"),
    -@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,
    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
      			       N_("synonym for --format=nul"),
      			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
      			       parse_format_cb),
    -+		OPT_BOOL(0, "all", &all_keys, N_("return all keys")),
    ++		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
      		OPT_END()
      	};
      
    - 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
    + 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
    + 		die(_("unsupported output format"));
      
     +	if (all_keys) {
     +		if (argc)
-- 
2.50.1 (Apple Git-155)
Previous: Eric SunshineNext: Lucas Seiki Oshiro
Message 15 of 30 in “repo: add --all to git-repo-info”
  1. repo: add --all to git-repo-infoLucas Seiki Oshiro, Sep 15, 2025
  2. Junio C HamanoSep 15, 2025
  3. Patrick SteinhardtSep 16, 2025
  4. Junio C HamanoSep 16, 2025
  5. Patrick SteinhardtSep 17, 2025
  6. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Oct 26, 2025
  7. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Oct 26, 2025
  8. Eric SunshineOct 26, 2025
  9. Eric SunshineOct 26, 2025
  10. Junio C HamanoOct 27, 2025
  11. Eric SunshineOct 27, 2025
  12. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Oct 26, 2025
  13. Eric SunshineOct 27, 2025
  14. Eric SunshineOct 27, 2025
  15. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 17, 2025
  16. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Nov 17, 2025
  17. Junio C HamanoNov 17, 2025
  18. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 17, 2025
  19. Junio C HamanoNov 17, 2025
  20. Lucas Seiki OshiroNov 18, 2025
  21. Junio C HamanoNov 18, 2025
  22. Lucas Seiki OshiroNov 20, 2025
  23. Eric SunshineNov 19, 2025
  24. Junio C HamanoNov 19, 2025
  25. Junio C HamanoNov 17, 2025
  26. 0/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 18, 2025
  27. 1/2 repo: factor out field printing to dedicated functionLucas Seiki Oshiro, Nov 18, 2025
  28. 2/2 repo: add --all to git-repo-infoLucas Seiki Oshiro, Nov 18, 2025
  29. Junio C HamanoNov 18, 2025
  30. Eric SunshineNov 19, 2025

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.