public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] repo: add new flag --keys to git-repo-info
@ 2025-12-07 19:02 Lucas Seiki Oshiro
  2025-12-07 22:14 ` Junio C Hamano
                   ` (8 more replies)
  0 siblings, 9 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-07 19:02 UTC (permalink / raw)
  To: git; +Cc: Lucas Seiki Oshiro

Currently, if the user wants to find what are the available keys,
they need to either check the documentation or to ask to all the
key-value pairs by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---

Hi!

After the Junio's suggestion [1], this patch adds a new flag --keys to
git-repo-info. This new flag only prints the available keys, without
printing the corresponding values.

This patch is based on top of master bdc5341ff6 (The sixth batch,
2025-12-05) with lo/repo-struct-z merged.

[1] https://lore.kernel.org/git/xmqq8qg3do99.fsf@gitster.g/

 Documentation/git-repo.adoc |  4 ++++
 builtin/repo.c              | 17 +++++++++++++++++
 t/t1900-repo.sh             | 13 ++-----------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index c4a78277df..f0f4d77db8 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
+git repo info --keys
 git repo structure [--format=(table|keyvalue|nul) | -z]
 
 DESCRIPTION
@@ -44,6 +45,9 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys`::
+List all the available keys, one per line.
+
 `structure [--format=(table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 0dd41b1778..45e9d59d55 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -16,6 +16,7 @@
 
 static const char *const repo_usage[] = {
 	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo info --keys",
 	"git repo structure [--format=(table|keyvalue|nul) | -z]",
 	NULL
 };
@@ -146,6 +147,16 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(void)
+{
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		puts(field->key);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -170,6 +181,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_KEYVALUE;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -179,10 +191,15 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+
+	if (show_keys)
+		return print_keys();
+
 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..d6e84a78e5 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH] repo: add new flag --keys to git-repo-info
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2025-12-07 22:14 ` Junio C Hamano
  2025-12-08 16:33   ` Lucas Seiki Oshiro
  2025-12-08  7:13 ` Patrick Steinhardt
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Junio C Hamano @ 2025-12-07 22:14 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git

Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:

> Currently, if the user wants to find what are the available keys,
> they need to either check the documentation or to ask to all the
> key-value pairs by using --all.
>
> Add a new flag --keys for listing only the available keys without
> listing the values.

We do not need to say "Currently," but other than that the above is
very well written.  Easy to grok and to the point.

>  [synopsis]
>  git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
> +git repo info --keys
>  git repo structure [--format=(table|keyvalue|nul) | -z]

So "git repo info --keys --all" or "git repo info --keys --format=..."
is not supported.  Does the implementation behave sensibly when given
such nonsense commands?  Let's see.

> @@ -170,6 +181,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
>  {
>  	enum output_format format = FORMAT_KEYVALUE;
>  	int all_keys = 0;
> +	int show_keys = 0;
>  	struct option options[] = {
>  		OPT_CALLBACK_F(0, "format", &format, N_("format"),
>  			       N_("output format"),
> @@ -179,10 +191,15 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
>  			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
>  			       parse_format_cb),
>  		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
> +		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
>  		OPT_END()
>  	};
>  
>  	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
> +
> +	if (show_keys)
> +		return print_keys();
> +
>  	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
>  		die(_("unsupported output format"));

OK, so it is:

    "git repo info --all --keys" and "git repo info --keys layout.bare"
    both behave as if "git repo --keys" was given, ignoring
    everything else.

Shouldn't "--keys" be explicitly marked incompatible with "--all"
and remaining keys in argc/argv[]?

While there is no strong reason why anybody must use NUL-terminated
output format, simply because repo_info_fields[] contains no tokens
with strange byte values, but just as principle, shouldn't

    "git repo info --keys -z"

do what is naturally expected?

Perhaps

	if (format != ...)
		die(_("unsupported output format"));

	if (show_keys && (all_keys || argc))
		die(_("--keys cannot be used with a <key> or --all"));

	if (show_keys)
		return print_keys(output_format);

with a trivial update to print_keys() to support NUL-terminated
records, instead of puts()?

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH] repo: add new flag --keys to git-repo-info
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2025-12-07 22:14 ` Junio C Hamano
@ 2025-12-08  7:13 ` Patrick Steinhardt
  2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2025-12-08  7:13 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git

On Sun, Dec 07, 2025 at 04:02:10PM -0300, Lucas Seiki Oshiro wrote:
> Currently, if the user wants to find what are the available keys,
> they need to either check the documentation or to ask to all the

This sentence doesn't quite parse. I think you wanted to say "ask for
all" instead of "ask to all" here.

All the other points were already covered by Junio, so I won't comment
on these parts.

Thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH] repo: add new flag --keys to git-repo-info
  2025-12-07 22:14 ` Junio C Hamano
@ 2025-12-08 16:33   ` Lucas Seiki Oshiro
  0 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-08 16:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Patrick Steinhardt


> We do not need to say "Currently," but other than that the above is
> very well written.  Easy to grok and to the point.

Thanks!

> Shouldn't "--keys" be explicitly marked incompatible with "--all"
> and remaining keys in argc/argv[]?

Yes, I'll work on that.

> While there is no strong reason why anybody must use NUL-terminated
> output format, simply because repo_info_fields[] contains no tokens
> with strange byte values, but just as principle, shouldn't
> 
>    "git repo info --keys -z"
> 
> do what is naturally expected?

Hmmm... Perhaps it's too much for this simple flag. `-z` is tied to
--format here, and if we want to support -z we'll also need to 
support --format.

What about adding a "default" format for --format? This way, it
would translate to:

- keyvalue, when using info without --keys
- table, when using structure
- using puts, when using info with --keys

Another solution, of course, would be aborting when --format, -z or
--all are used with --keys.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 0/2] repo: add new flag --keys to git-repo-info
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2025-12-07 22:14 ` Junio C Hamano
  2025-12-08  7:13 ` Patrick Steinhardt
@ 2025-12-09 19:36 ` Lucas Seiki Oshiro
  2025-12-09 19:36   ` [PATCH v2 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
                     ` (2 more replies)
  2026-01-09 20:31 ` [PATCH v3 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
                   ` (5 subsequent siblings)
  8 siblings, 3 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-09 19:36 UTC (permalink / raw)
  To: git; +Cc: ps, Lucas Seiki Oshiro

Hi!

This patch series adds a new flag --keys to git-repo-info. This new flag
only prints the available keys, without printing the corresponding
values.

The main change in this version is the compatibility with the flags -z
and --format, allowing the keys to be printed following the
null-terminated format.

This patch is based on top of master bdc5341ff6 (The sixth batch, 
2025-12-05) with lo/repo-struct-z merged.

Lucas Seiki Oshiro (2):
  repo: add a default output format to enum output_format
  repo: add new flag --keys to git-repo-info

 Documentation/git-repo.adoc | 11 ++++++++++
 builtin/repo.c              | 41 ++++++++++++++++++++++++++++++++++++-
 t/t1900-repo.sh             | 33 +++++++++++++++++++----------
 3 files changed, 73 insertions(+), 12 deletions(-)

Range-diff against v1:
-:  ---------- > 1:  9eb2549806 repo: add a default output format to enum output_format
1:  1b9b7dceb7 ! 2:  c5b7ba8824 repo: add new flag --keys to git-repo-info
    @@ Metadata
      ## Commit message ##
         repo: add new flag --keys to git-repo-info
     
    -    Currently, if the user wants to find what are the available keys,
    -    they need to either check the documentation or to ask to all the
    -    key-value pairs by using --all.
    +    If the user wants to find what are the available keys, they need to
    +    either check the documentation or to ask for all the key-value pairs
    +    by using --all.
     
         Add a new flag --keys for listing only the available keys without
         listing the values.
    @@ Documentation/git-repo.adoc: SYNOPSIS
      --------
      [synopsis]
      git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
    -+git repo info --keys
    ++git repo info --keys [--format=(default|nul) | -z]
      git repo structure [--format=(table|keyvalue|nul) | -z]
      
      DESCRIPTION
    @@ Documentation/git-repo.adoc: supported:
      +
      `-z` is an alias for `--format=nul`.
      
    -+`info --keys`::
    -+List all the available keys, one per line.
    ++`info --keys [--format=(default|nul) | -z]`::
    ++	List all the available keys, one per line. The output format can be chosen
    ++	through the flag `--format`. The following formats are supported:
    +++
    ++`default`:::
    ++	output the keys one per line.
    ++
    ++`nul`:::
    ++	similar to `default`, but using a NUL character after each value.
     +
      `structure [--format=(table|keyvalue|nul) | -z]`::
      	Retrieve statistics about the current repository structure. The
    @@ builtin/repo.c
      
      static const char *const repo_usage[] = {
      	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
    -+	"git repo info --keys",
    ++	"git repo info --keys [--format=(default|nul) | -z]",
      	"git repo structure [--format=(table|keyvalue|nul) | -z]",
      	NULL
      };
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      	return 0;
      }
      
    -+static int print_keys(void)
    ++static int print_keys(enum output_format format)
     +{
    ++	char sep;
    ++
    ++	switch (format) {
    ++	case FORMAT_DEFAULT:
    ++		sep = '\n';
    ++		break;
    ++	case FORMAT_NUL_TERMINATED:
    ++		sep = '\0';
    ++		break;
    ++	default:
    ++		die(_("--keys can only be used with --format=default or --format=nul"));
    ++	}
    ++
     +	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
     +		const struct field *field = &repo_info_fields[i];
    -+		puts(field->key);
    ++		printf("%s%c", field->key, sep);
     +	}
     +
     +	return 0;
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      {
     @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
      {
    - 	enum output_format format = FORMAT_KEYVALUE;
    + 	enum output_format format = FORMAT_DEFAULT;
      	int all_keys = 0;
     +	int show_keys = 0;
      	struct option options[] = {
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
      	};
      
      	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
    + 
    ++	if (show_keys && (all_keys || argc))
    ++		die(_("--keys cannot be used with a <key> or --all"));
     +
     +	if (show_keys)
    -+		return print_keys();
    ++		return print_keys(format);
     +
    - 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
    - 		die(_("unsupported output format"));
    + 	if (format == FORMAT_DEFAULT)
    + 		format = FORMAT_KEYVALUE;
      
     
      ## t/t1900-repo.sh ##
    @@ t/t1900-repo.sh: test_expect_success 'git repo info uses the last requested form
      	git repo info --all >actual &&
      	test_cmp expect actual
      '
    +@@ t/t1900-repo.sh: test_expect_success 'git repo info --all <key> aborts' '
    + 	test_cmp expect actual
    + '
    + 
    ++test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
    ++	git repo info --keys --format=default >default &&
    ++	lf_to_nul <default > expect &&
    ++	git repo info --keys --format=nul >actual &&
    ++	test_cmp expect actual
    ++'
    ++
    ++test_expect_success 'git repo info --keys aborts when using --format other than default or nul' '
    ++	echo "fatal: --keys can only be used with --format=default or --format=nul" >expect &&
    ++	test_must_fail git repo info --keys --format=keyvalue 2>actual &&
    ++	test_cmp expect actual
    ++'
    ++
    ++test_expect_success 'git repo info --keys aborts when requesting keys' '
    ++	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
    ++	test_must_fail git repo info --keys --all 2>actual_all &&
    ++	test_must_fail git repo info --keys some.key 2>actual_key &&
    ++	test_cmp expect actual_all &&
    ++	test_cmp expect actual_key
    ++'
    + test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v2 1/2] repo: add a default output format to enum output_format
  2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
@ 2025-12-09 19:36   ` Lucas Seiki Oshiro
  2026-01-05 14:18     ` Patrick Steinhardt
  2025-12-09 19:36   ` [PATCH v2 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2026-01-05 13:57   ` [PATCH v2 0/2] " Lucas Seiki Oshiro
  2 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-09 19:36 UTC (permalink / raw)
  To: git; +Cc: ps, Lucas Seiki Oshiro

Add a `FORMAT_DEFAULT` value to `enum output_format`. Change the initial
value of `format` to `FORMAT_DEFAULT` in cmd_repo_info, indicating that
the initial value hasn't been changed. Also map the string "default" to
this new value in `parse_format_cb`, allowing future patches to add
support to --format=default.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 builtin/repo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/builtin/repo.c b/builtin/repo.c
index 0dd41b1778..1cd12e7eea 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -23,6 +23,7 @@ static const char *const repo_usage[] = {
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
+	FORMAT_DEFAULT,
 	FORMAT_TABLE,
 	FORMAT_KEYVALUE,
 	FORMAT_NUL_TERMINATED,
@@ -159,6 +160,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_KEYVALUE;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
+	else if (!strcmp(arg, "default"))
+		*format = FORMAT_DEFAULT;
 	else
 		die(_("invalid format '%s'"), arg);
 
@@ -168,7 +171,7 @@ static int parse_format_cb(const struct option *opt,
 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			 struct repository *repo)
 {
-	enum output_format format = FORMAT_KEYVALUE;
+	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -183,6 +186,10 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_KEYVALUE;
+
 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v2 2/2] repo: add new flag --keys to git-repo-info
  2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
  2025-12-09 19:36   ` [PATCH v2 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
@ 2025-12-09 19:36   ` Lucas Seiki Oshiro
  2026-01-05 14:18     ` Patrick Steinhardt
  2026-01-05 13:57   ` [PATCH v2 0/2] " Lucas Seiki Oshiro
  2 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-09 19:36 UTC (permalink / raw)
  To: git; +Cc: ps, Lucas Seiki Oshiro

If the user wants to find what are the available keys, they need to
either check the documentation or to ask for all the key-value pairs
by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 11 +++++++++++
 builtin/repo.c              | 32 ++++++++++++++++++++++++++++++++
 t/t1900-repo.sh             | 33 ++++++++++++++++++++++-----------
 3 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index c4a78277df..fd0683631c 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
+git repo info --keys [--format=(default|nul) | -z]
 git repo structure [--format=(table|keyvalue|nul) | -z]
 
 DESCRIPTION
@@ -44,6 +45,16 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys [--format=(default|nul) | -z]`::
+	List all the available keys, one per line. The output format can be chosen
+	through the flag `--format`. The following formats are supported:
++
+`default`:::
+	output the keys one per line.
+
+`nul`:::
+	similar to `default`, but using a NUL character after each value.
+
 `structure [--format=(table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 1cd12e7eea..48341f9245 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -16,6 +16,7 @@
 
 static const char *const repo_usage[] = {
 	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo info --keys [--format=(default|nul) | -z]",
 	"git repo structure [--format=(table|keyvalue|nul) | -z]",
 	NULL
 };
@@ -147,6 +148,29 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(enum output_format format)
+{
+	char sep;
+
+	switch (format) {
+	case FORMAT_DEFAULT:
+		sep = '\n';
+		break;
+	case FORMAT_NUL_TERMINATED:
+		sep = '\0';
+		break;
+	default:
+		die(_("--keys can only be used with --format=default or --format=nul"));
+	}
+
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		printf("%s%c", field->key, sep);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -173,6 +197,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -182,11 +207,18 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
 
+	if (show_keys && (all_keys || argc))
+		die(_("--keys cannot be used with a <key> or --all"));
+
+	if (show_keys)
+		return print_keys(format);
+
 	if (format == FORMAT_DEFAULT)
 		format = FORMAT_KEYVALUE;
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..e8802413a6 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
@@ -131,4 +122,24 @@ test_expect_success 'git repo info --all <key> aborts' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
+	git repo info --keys --format=default >default &&
+	lf_to_nul <default > expect &&
+	git repo info --keys --format=nul >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when using --format other than default or nul' '
+	echo "fatal: --keys can only be used with --format=default or --format=nul" >expect &&
+	test_must_fail git repo info --keys --format=keyvalue 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when requesting keys' '
+	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
+	test_must_fail git repo info --keys --all 2>actual_all &&
+	test_must_fail git repo info --keys some.key 2>actual_key &&
+	test_cmp expect actual_all &&
+	test_cmp expect actual_key
+'
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 0/2] repo: add new flag --keys to git-repo-info
  2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
  2025-12-09 19:36   ` [PATCH v2 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
  2025-12-09 19:36   ` [PATCH v2 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-05 13:57   ` Lucas Seiki Oshiro
  2026-01-05 14:19     ` Patrick Steinhardt
  2 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-05 13:57 UTC (permalink / raw)
  To: git; +Cc: ps, Junio C Hamano

Hello, everyone, and happy new year!

Sorry to bother you with this, but do you have any comments about this
patch?

Thanks!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 2/2] repo: add new flag --keys to git-repo-info
  2025-12-09 19:36   ` [PATCH v2 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-05 14:18     ` Patrick Steinhardt
  0 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-05 14:18 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git

On Tue, Dec 09, 2025 at 04:36:03PM -0300, Lucas Seiki Oshiro wrote:
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index c4a78277df..fd0683631c 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -9,6 +9,7 @@ SYNOPSIS
>  --------
>  [synopsis]
>  git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
> +git repo info --keys [--format=(default|nul) | -z]
>  git repo structure [--format=(table|keyvalue|nul) | -z]
>  
>  DESCRIPTION

The synopsis should have been updated in the preceding commit to mention
"default" for `git repo info`.

> @@ -131,4 +122,24 @@ test_expect_success 'git repo info --all <key> aborts' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
> +	git repo info --keys --format=default >default &&
> +	lf_to_nul <default > expect &&

Style nit: there shouldn't be a space between "> expect".

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 1/2] repo: add a default output format to enum output_format
  2025-12-09 19:36   ` [PATCH v2 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
@ 2026-01-05 14:18     ` Patrick Steinhardt
  2026-01-07 21:28       ` Lucas Seiki Oshiro
  0 siblings, 1 reply; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-05 14:18 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git

On Tue, Dec 09, 2025 at 04:36:02PM -0300, Lucas Seiki Oshiro wrote:
> Add a `FORMAT_DEFAULT` value to `enum output_format`. Change the initial
> value of `format` to `FORMAT_DEFAULT` in cmd_repo_info, indicating that
> the initial value hasn't been changed. Also map the string "default" to
> this new value in `parse_format_cb`, allowing future patches to add
> support to --format=default.

This is missing a test. It would for example be nice to verify that
"--format=nul --format=default" does the expected thing.

Also, I didn't see `git repo structure` being updated. Should we do that
so that both subcommands know to handle the "default" format?

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 0/2] repo: add new flag --keys to git-repo-info
  2026-01-05 13:57   ` [PATCH v2 0/2] " Lucas Seiki Oshiro
@ 2026-01-05 14:19     ` Patrick Steinhardt
  0 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-05 14:19 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, Junio C Hamano

Hi Lucas,

On Mon, Jan 05, 2026 at 10:57:23AM -0300, Lucas Seiki Oshiro wrote:
> Hello, everyone, and happy new year!
> 
> Sorry to bother you with this, but do you have any comments about this
> patch?

no need to be sorry, I lost track of this series and didn't have it on
my radar anymore. I've left some comments now, thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 1/2] repo: add a default output format to enum output_format
  2026-01-05 14:18     ` Patrick Steinhardt
@ 2026-01-07 21:28       ` Lucas Seiki Oshiro
  2026-01-08  6:13         ` Patrick Steinhardt
  0 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-07 21:28 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git


> This is missing a test.

Indeed, I'll add a test for `--format=default`.

> It would for example be nice to verify that
> "--format=nul --format=default" does the expected thing.

Would it be necessary? We already have a test asserting that the
last "--format" wins:

test_expect_success 'git repo info uses the last requested format' '
	echo "layout.bare=false" >expected &&
	git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
	test_cmp expected actual
'

> Also, I didn't see `git repo structure` being updated. Should we do that
> so that both subcommands know to handle the "default" format?

Sure! I'll do that!

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v2 1/2] repo: add a default output format to enum output_format
  2026-01-07 21:28       ` Lucas Seiki Oshiro
@ 2026-01-08  6:13         ` Patrick Steinhardt
  0 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-08  6:13 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git

On Wed, Jan 07, 2026 at 06:28:59PM -0300, Lucas Seiki Oshiro wrote:
> 
> > This is missing a test.
> 
> Indeed, I'll add a test for `--format=default`.
> 
> > It would for example be nice to verify that
> > "--format=nul --format=default" does the expected thing.
> 
> Would it be necessary? We already have a test asserting that the
> last "--format" wins:
> 
> test_expect_success 'git repo info uses the last requested format' '
> 	echo "layout.bare=false" >expected &&
> 	git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
> 	test_cmp expected actual
> '

Yup, but we don't have any test that verifies we do the right thing when
the user asks for the default format. So it's mostly an additional check
that the default format can be requested as expected, which would in the
normal case be a no-op as, well, it's the default. So if you specify a
different format before we verify that it can reset to the default.

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 0/2] repo: add --format=default and --keys
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (2 preceding siblings ...)
  2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
@ 2026-01-09 20:31 ` Lucas Seiki Oshiro
  2026-01-10  6:48   ` Junio C Hamano
  2026-01-09 20:31 ` [PATCH v3 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-09 20:31 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, Lucas Seiki Oshiro

Hi!

The main change in this version is that git-repo-structure now supports
`--format=default`. This way, both git-repo-info and git-repo-structure
now can be used with `--format=default`, which resets the output format
to the default one (`keyvalue` in repo-info, `table` in repo-structure).

I'm also cc'ing Justin to see if he agrees with this change to
git-repo-structure.

Lucas Seiki Oshiro (2):
  repo: add a default output format to enum output_format
  repo: add new flag --keys to git-repo-info

 Documentation/git-repo.adoc | 30 ++++++++++++++++------
 builtin/repo.c              | 50 ++++++++++++++++++++++++++++++++++---
 t/t1900-repo.sh             | 46 ++++++++++++++++++++++++++--------
 t/t1901-repo-structure.sh   | 22 ++++++++++++++++
 4 files changed, 126 insertions(+), 22 deletions(-)

Range-diff against v2:
1:  9eb2549806 ! 1:  97f8eee687 repo: add a default output format to enum output_format
    @@ Metadata
      ## Commit message ##
         repo: add a default output format to enum output_format
     
    -    Add a `FORMAT_DEFAULT` value to `enum output_format`. Change the initial
    -    value of `format` to `FORMAT_DEFAULT` in cmd_repo_info, indicating that
    -    the initial value hasn't been changed. Also map the string "default" to
    -    this new value in `parse_format_cb`, allowing future patches to add
    -    support to --format=default.
    +    Add "default" as an option for --format in both git-repo-info and
    +    git-repo-structure. Using `--format=default` makes those commands use
    +    their default output format.
     
         Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
     
    + ## Documentation/git-repo.adoc ##
    +@@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repository
    + SYNOPSIS
    + --------
    + [synopsis]
    +-git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
    +-git repo structure [--format=(table|keyvalue|nul) | -z]
    ++git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
    ++git repo structure [--format=(default|table|keyvalue|nul) | -z]
    + 
    + DESCRIPTION
    + -----------
    +@@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
    + 
    + COMMANDS
    + --------
    +-`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
    ++`info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]`::
    + 	Retrieve metadata-related information about the current repository. Only
    + 	the requested data will be returned based on their keys (see "INFO KEYS"
    + 	section below).
    +@@ Documentation/git-repo.adoc: requested. The `--all` flag requests the values for all the available keys.
    + The output format can be chosen through the flag `--format`. Two formats are
    + supported:
    + +
    ++`default`:::
    ++	synonym for `keyvalue`.
    ++
    + `keyvalue`:::
    + 	output key-value pairs one per line using the `=` character as
    + 	the delimiter between the key and the value. Values containing "unusual"
    + 	characters are quoted as explained for the configuration variable
    +-	`core.quotePath` (see linkgit:git-config[1]). This is the default.
    ++	`core.quotePath` (see linkgit:git-config[1]).
    + 
    + `nul`:::
    + 	similar to `keyvalue`, but using a newline character as the delimiter
    +@@ Documentation/git-repo.adoc: supported:
    + +
    + `-z` is an alias for `--format=nul`.
    + 
    +-`structure [--format=(table|keyvalue|nul) | -z]`::
    ++`structure [--format=(default|table|keyvalue|nul) | -z]`::
    + 	Retrieve statistics about the current repository structure. The
    + 	following kinds of information are reported:
    + +
    +@@ Documentation/git-repo.adoc: supported:
    + The output format can be chosen through the flag `--format`. Three formats are
    + supported:
    + +
    ++`default`:::
    ++	synonym for `table`.
    ++
    + `table`:::
    + 	Outputs repository stats in a human-friendly table. This format may
    +-	change and is not intended for machine parsing. This is the default
    +-	format.
    ++	change and is not intended for machine parsing.
    + 
    + `keyvalue`:::
    + 	Each line of output contains a key-value pair for a repository stat.
    +
      ## builtin/repo.c ##
    -@@ builtin/repo.c: static const char *const repo_usage[] = {
    +@@
    + #include "utf8.h"
    + 
    + static const char *const repo_usage[] = {
    +-	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
    +-	"git repo structure [--format=(table|keyvalue|nul) | -z]",
    ++	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
    ++	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
    + 	NULL
    + };
    + 
      typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
      
      enum output_format {
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
      	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
      		die(_("unsupported output format"));
      
    +@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    + 	struct stats_table table = {
    + 		.rows = STRING_LIST_INIT_DUP,
    + 	};
    +-	enum output_format format = FORMAT_TABLE;
    ++	enum output_format format = FORMAT_DEFAULT;
    + 	struct repo_structure stats = { 0 };
    + 	struct rev_info revs;
    + 	int show_progress = -1;
    +@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    + 	if (argc)
    + 		usage(_("too many arguments"));
    + 
    ++	if (format == FORMAT_DEFAULT)
    ++		format = FORMAT_TABLE;
    ++
    + 	repo_init_revisions(repo, &revs, prefix);
    + 
    + 	if (show_progress < 0)
    +
    + ## t/t1900-repo.sh ##
    +@@ t/t1900-repo.sh: test_expect_success 'git repo info --all <key> aborts' '
    + 	test_cmp expect actual
    + '
    + 
    ++test_expect_success '--format=default is a synonym for --format=keyvalue' '
    ++	git repo info --all --format=keyvalue >expect &&
    ++	git repo info --all --format=default >actual &&
    ++	test_cmp expect actual
    ++'
    ++
    ++test_expect_success '--format=default resets the format' '
    ++	git repo info --all >expect &&
    ++	git repo info --all --format=nul --format=default >actual &&
    ++	test_cmp expect actual
    ++'
    ++
    + test_done
    +
    + ## t/t1901-repo-structure.sh ##
    +@@ t/t1901-repo-structure.sh: test_expect_success 'progress meter option' '
    + 	)
    + '
    + 
    ++test_expect_success '--format=default is a synonym for --format=table' '
    ++	test_when_finished "rm -rf repo" &&
    ++	git init repo &&
    ++	(
    ++		cd repo &&
    ++		git repo structure --format=table >expect &&
    ++		git repo structure --format=default >actual &&
    ++		test_cmp expect actual
    ++	)
    ++'
    ++
    ++test_expect_success '--format=default resets the format' '
    ++	test_when_finished "rm -rf repo" &&
    ++	git init repo &&
    ++	(
    ++		cd repo &&
    ++		git repo structure >expect &&
    ++		git repo structure --format=nul --format=default >actual &&
    ++		test_cmp expect actual
    ++	)
    ++'
    ++
    + test_done
2:  c5b7ba8824 ! 2:  0c7d3bca32 repo: add new flag --keys to git-repo-info
    @@ Documentation/git-repo.adoc
     @@ Documentation/git-repo.adoc: SYNOPSIS
      --------
      [synopsis]
    - git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
    + git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
     +git repo info --keys [--format=(default|nul) | -z]
    - git repo structure [--format=(table|keyvalue|nul) | -z]
    + git repo structure [--format=(default|table|keyvalue|nul) | -z]
      
      DESCRIPTION
     @@ Documentation/git-repo.adoc: supported:
    @@ Documentation/git-repo.adoc: supported:
     +`nul`:::
     +	similar to `default`, but using a NUL character after each value.
     +
    - `structure [--format=(table|keyvalue|nul) | -z]`::
    + `structure [--format=(default|table|keyvalue|nul) | -z]`::
      	Retrieve statistics about the current repository structure. The
      	following kinds of information are reported:
     
    @@ builtin/repo.c
     @@
      
      static const char *const repo_usage[] = {
    - 	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
    + 	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
     +	"git repo info --keys [--format=(default|nul) | -z]",
    - 	"git repo structure [--format=(table|keyvalue|nul) | -z]",
    + 	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
      	NULL
      };
     @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
    @@ t/t1900-repo.sh: test_expect_success 'git repo info uses the last requested form
      	git repo info --all >actual &&
      	test_cmp expect actual
      '
    -@@ t/t1900-repo.sh: test_expect_success 'git repo info --all <key> aborts' '
    +@@ t/t1900-repo.sh: test_expect_success '--format=default resets the format' '
      	test_cmp expect actual
      '
      
     +test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
     +	git repo info --keys --format=default >default &&
    -+	lf_to_nul <default > expect &&
    ++	lf_to_nul <default >expect &&
     +	git repo info --keys --format=nul >actual &&
     +	test_cmp expect actual
     +'
    @@ t/t1900-repo.sh: test_expect_success 'git repo info --all <key> aborts' '
     +	test_cmp expect actual_all &&
     +	test_cmp expect actual_key
     +'
    ++
      test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v3 1/2] repo: add a default output format to enum output_format
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (3 preceding siblings ...)
  2026-01-09 20:31 ` [PATCH v3 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
@ 2026-01-09 20:31 ` Lucas Seiki Oshiro
  2026-01-09 20:31 ` [PATCH v3 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-09 20:31 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, Lucas Seiki Oshiro

Add "default" as an option for --format in both git-repo-info and
git-repo-structure. Using `--format=default` makes those commands use
their default output format.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 19 ++++++++++++-------
 builtin/repo.c              | 18 ++++++++++++++----
 t/t1900-repo.sh             | 12 ++++++++++++
 t/t1901-repo-structure.sh   | 22 ++++++++++++++++++++++
 4 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 7d70270dfa..fa0e6600af 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
 SYNOPSIS
 --------
 [synopsis]
-git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul) | -z]
+git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
+git repo structure [--format=(default|table|keyvalue|nul) | -z]
 
 DESCRIPTION
 -----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
 
 COMMANDS
 --------
-`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
+`info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]`::
 	Retrieve metadata-related information about the current repository. Only
 	the requested data will be returned based on their keys (see "INFO KEYS"
 	section below).
@@ -30,11 +30,14 @@ requested. The `--all` flag requests the values for all the available keys.
 The output format can be chosen through the flag `--format`. Two formats are
 supported:
 +
+`default`:::
+	synonym for `keyvalue`.
+
 `keyvalue`:::
 	output key-value pairs one per line using the `=` character as
 	the delimiter between the key and the value. Values containing "unusual"
 	characters are quoted as explained for the configuration variable
-	`core.quotePath` (see linkgit:git-config[1]). This is the default.
+	`core.quotePath` (see linkgit:git-config[1]).
 
 `nul`:::
 	similar to `keyvalue`, but using a newline character as the delimiter
@@ -44,7 +47,7 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
-`structure [--format=(table|keyvalue|nul) | -z]`::
+`structure [--format=(default|table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
 +
@@ -56,10 +59,12 @@ supported:
 The output format can be chosen through the flag `--format`. Three formats are
 supported:
 +
+`default`:::
+	synonym for `table`.
+
 `table`:::
 	Outputs repository stats in a human-friendly table. This format may
-	change and is not intended for machine parsing. This is the default
-	format.
+	change and is not intended for machine parsing.
 
 `keyvalue`:::
 	Each line of output contains a key-value pair for a repository stat.
diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..306d3fa2df 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -17,14 +17,15 @@
 #include "utf8.h"
 
 static const char *const repo_usage[] = {
-	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
-	"git repo structure [--format=(table|keyvalue|nul) | -z]",
+	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
 	NULL
 };
 
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
+	FORMAT_DEFAULT,
 	FORMAT_TABLE,
 	FORMAT_KEYVALUE,
 	FORMAT_NUL_TERMINATED,
@@ -161,6 +162,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_KEYVALUE;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
+	else if (!strcmp(arg, "default"))
+		*format = FORMAT_DEFAULT;
 	else
 		die(_("invalid format '%s'"), arg);
 
@@ -170,7 +173,7 @@ static int parse_format_cb(const struct option *opt,
 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			 struct repository *repo)
 {
-	enum output_format format = FORMAT_KEYVALUE;
+	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -185,6 +188,10 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_KEYVALUE;
+
 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
@@ -638,7 +645,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 	struct stats_table table = {
 		.rows = STRING_LIST_INIT_DUP,
 	};
-	enum output_format format = FORMAT_TABLE;
+	enum output_format format = FORMAT_DEFAULT;
 	struct repo_structure stats = { 0 };
 	struct rev_info revs;
 	int show_progress = -1;
@@ -658,6 +665,9 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 	if (argc)
 		usage(_("too many arguments"));
 
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_TABLE;
+
 	repo_init_revisions(repo, &revs, prefix);
 
 	if (show_progress < 0)
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..e6670f0f58 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -131,4 +131,16 @@ test_expect_success 'git repo info --all <key> aborts' '
 	test_cmp expect actual
 '
 
+test_expect_success '--format=default is a synonym for --format=keyvalue' '
+	git repo info --all --format=keyvalue >expect &&
+	git repo info --all --format=default >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '--format=default resets the format' '
+	git repo info --all >expect &&
+	git repo info --all --format=nul --format=default >actual &&
+	test_cmp expect actual
+'
+
 test_done
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 17ff164b05..9c5054c8db 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -181,4 +181,26 @@ test_expect_success 'progress meter option' '
 	)
 '
 
+test_expect_success '--format=default is a synonym for --format=table' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git repo structure --format=table >expect &&
+		git repo structure --format=default >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success '--format=default resets the format' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git repo structure >expect &&
+		git repo structure --format=nul --format=default >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v3 2/2] repo: add new flag --keys to git-repo-info
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (4 preceding siblings ...)
  2026-01-09 20:31 ` [PATCH v3 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
@ 2026-01-09 20:31 ` Lucas Seiki Oshiro
  2026-01-10 12:04   ` Jean-Noël AVILA
  2026-01-12  8:40   ` Patrick Steinhardt
  2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-09 20:31 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, Lucas Seiki Oshiro

If the user wants to find what are the available keys, they need to
either check the documentation or to ask for all the key-value pairs
by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 11 +++++++++++
 builtin/repo.c              | 32 ++++++++++++++++++++++++++++++++
 t/t1900-repo.sh             | 34 +++++++++++++++++++++++-----------
 3 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index fa0e6600af..4471816cc8 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
+git repo info --keys [--format=(default|nul) | -z]
 git repo structure [--format=(default|table|keyvalue|nul) | -z]
 
 DESCRIPTION
@@ -47,6 +48,16 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys [--format=(default|nul) | -z]`::
+	List all the available keys, one per line. The output format can be chosen
+	through the flag `--format`. The following formats are supported:
++
+`default`:::
+	output the keys one per line.
+
+`nul`:::
+	similar to `default`, but using a NUL character after each value.
+
 `structure [--format=(default|table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 306d3fa2df..bc10b2da0b 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -18,6 +18,7 @@
 
 static const char *const repo_usage[] = {
 	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo info --keys [--format=(default|nul) | -z]",
 	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
 	NULL
 };
@@ -149,6 +150,29 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(enum output_format format)
+{
+	char sep;
+
+	switch (format) {
+	case FORMAT_DEFAULT:
+		sep = '\n';
+		break;
+	case FORMAT_NUL_TERMINATED:
+		sep = '\0';
+		break;
+	default:
+		die(_("--keys can only be used with --format=default or --format=nul"));
+	}
+
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		printf("%s%c", field->key, sep);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -175,6 +199,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -184,11 +209,18 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
 
+	if (show_keys && (all_keys || argc))
+		die(_("--keys cannot be used with a <key> or --all"));
+
+	if (show_keys)
+		return print_keys(format);
+
 	if (format == FORMAT_DEFAULT)
 		format = FORMAT_KEYVALUE;
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index e6670f0f58..14533b95a0 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
@@ -143,4 +134,25 @@ test_expect_success '--format=default resets the format' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
+	git repo info --keys --format=default >default &&
+	lf_to_nul <default >expect &&
+	git repo info --keys --format=nul >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when using --format other than default or nul' '
+	echo "fatal: --keys can only be used with --format=default or --format=nul" >expect &&
+	test_must_fail git repo info --keys --format=keyvalue 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when requesting keys' '
+	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
+	test_must_fail git repo info --keys --all 2>actual_all &&
+	test_must_fail git repo info --keys some.key 2>actual_key &&
+	test_cmp expect actual_all &&
+	test_cmp expect actual_key
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 0/2] repo: add --format=default and --keys
  2026-01-09 20:31 ` [PATCH v3 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
@ 2026-01-10  6:48   ` Junio C Hamano
  2026-01-10  7:02     ` Junio C Hamano
  0 siblings, 1 reply; 40+ messages in thread
From: Junio C Hamano @ 2026-01-10  6:48 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, ps, jltobler

Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:

> Hi!
>
> The main change in this version is that git-repo-structure now supports
> `--format=default`. This way, both git-repo-info and git-repo-structure
> now can be used with `--format=default`, which resets the output format
> to the default one (`keyvalue` in repo-info, `table` in repo-structure).
>
> I'm also cc'ing Justin to see if he agrees with this change to
> git-repo-structure.
>
> Lucas Seiki Oshiro (2):
>   repo: add a default output format to enum output_format
>   repo: add new flag --keys to git-repo-info

How does the bottommost commit relate to what has been queued on
lo/repo-info-keys topic as ac3e74d2 (repo: add new flag --keys to
git-repo-info, 2025-12-09)?


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 0/2] repo: add --format=default and --keys
  2026-01-10  6:48   ` Junio C Hamano
@ 2026-01-10  7:02     ` Junio C Hamano
  0 siblings, 0 replies; 40+ messages in thread
From: Junio C Hamano @ 2026-01-10  7:02 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, ps, jltobler

Junio C Hamano <gitster@pobox.com> writes:

>> Lucas Seiki Oshiro (2):
>>   repo: add a default output format to enum output_format
>>   repo: add new flag --keys to git-repo-info
>
> How does the bottommost commit relate to what has been queued on
> lo/repo-info-keys topic as ac3e74d2 (repo: add new flag --keys to
> git-repo-info, 2025-12-09)?

Ah, nevermind.  These two are designed to replace the two patches on
lo/repo-info-keys topic, so I'll discard the old ones and replace.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 2/2] repo: add new flag --keys to git-repo-info
  2026-01-09 20:31 ` [PATCH v3 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-10 12:04   ` Jean-Noël AVILA
  2026-01-10 22:00     ` Lucas Seiki Oshiro
  2026-01-12  8:40   ` Patrick Steinhardt
  1 sibling, 1 reply; 40+ messages in thread
From: Jean-Noël AVILA @ 2026-01-10 12:04 UTC (permalink / raw)
  To: git, Lucas Seiki Oshiro; +Cc: ps, gitster, jltobler, Lucas Seiki Oshiro

On Friday, 9 January 2026 21:31:53 CET Lucas Seiki Oshiro wrote:
> If the user wants to find what are the available keys, they need to
> either check the documentation or to ask for all the key-value pairs
> by using --all.
> 
> Add a new flag --keys for listing only the available keys without
> listing the values.
> 
> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
> ---
>  Documentation/git-repo.adoc | 11 +++++++++++
>  builtin/repo.c              | 32 ++++++++++++++++++++++++++++++++
>  t/t1900-repo.sh             | 34 +++++++++++++++++++++++-----------
>  3 files changed, 66 insertions(+), 11 deletions(-)
> 
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index fa0e6600af..4471816cc8 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -9,6 +9,7 @@ SYNOPSIS
>  --------
>  [synopsis]
>  git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
> +git repo info --keys [--format=(default|nul) | -z]
>  git repo structure [--format=(default|table|keyvalue|nul) | -z]
> 
>  DESCRIPTION
> @@ -47,6 +48,16 @@ supported:
>  +
>  `-z` is an alias for `--format=nul`.
> 
> +`info --keys [--format=(default|nul) | -z]`::
> +	List all the available keys, one per line. The output format can be 
chosen
> +	through the flag `--format`. The following formats are supported:
> ++
> +`default`:::
> +	output the keys one per line.
> +
> +`nul`:::
> +	similar to `default`, but using a NUL character after each value.

We use the placeholder format for character names: _NUL_





^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 2/2] repo: add new flag --keys to git-repo-info
  2026-01-10 12:04   ` Jean-Noël AVILA
@ 2026-01-10 22:00     ` Lucas Seiki Oshiro
  0 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-10 22:00 UTC (permalink / raw)
  To: Jean-Noël AVILA; +Cc: git, ps, gitster, jltobler


> We use the placeholder format for character names: _NUL_

Thanks. I'll change it in v4 and I'll change other occurrences in this
document in future patches.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v3 2/2] repo: add new flag --keys to git-repo-info
  2026-01-09 20:31 ` [PATCH v3 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2026-01-10 12:04   ` Jean-Noël AVILA
@ 2026-01-12  8:40   ` Patrick Steinhardt
  1 sibling, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-12  8:40 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler

On Fri, Jan 09, 2026 at 05:31:53PM -0300, Lucas Seiki Oshiro wrote:
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index fa0e6600af..4471816cc8 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -47,6 +48,16 @@ supported:
>  +
>  `-z` is an alias for `--format=nul`.
>  
> +`info --keys [--format=(default|nul) | -z]`::
> +	List all the available keys, one per line. The output format can be chosen
> +	through the flag `--format`. The following formats are supported:
> ++
> +`default`:::
> +	output the keys one per line.
> +
> +`nul`:::
> +	similar to `default`, but using a NUL character after each value.
> +
>  `structure [--format=(default|table|keyvalue|nul) | -z]`::
>  	Retrieve statistics about the current repository structure. The
>  	following kinds of information are reported:

I think it's slightly unfortunate that the default format cannot be
explicitly chosen. "keyvalue" of course doesn't make sense, but maybe we
should have a format "newline" that can be specified?

Other than that the patches look good to me, thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 0/2] repo: add --format=default and --keys
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (5 preceding siblings ...)
  2026-01-09 20:31 ` [PATCH v3 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-19 20:20 ` Lucas Seiki Oshiro
  2026-01-19 20:20   ` [PATCH v4 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
                     ` (2 more replies)
  2026-01-23 16:34 ` [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  8 siblings, 3 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-19 20:20 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

Hello, again!

This v4 addresses these two issues:

1. NUL was replaced by _NUL_ in the documentation
2. Now, the default output format of `git repo info --keys` is "lines"
   and "default" is a synonym for it. I prefer to called it "lines"
   instead of "newline" (as suggested by Patrick) because I thought that
   it would be clear to the user

Lucas Seiki Oshiro (2):
  repo: add a default output format to enum output_format
  repo: add new flag --keys to git-repo-info

 Documentation/git-repo.adoc | 33 +++++++++++++++++-----
 builtin/repo.c              | 56 ++++++++++++++++++++++++++++++++++---
 t/t1900-repo.sh             | 54 +++++++++++++++++++++++++++--------
 t/t1901-repo-structure.sh   | 22 +++++++++++++++
 4 files changed, 143 insertions(+), 22 deletions(-)

Range-diff against v3:
1:  97f8eee687 = 1:  7dabd62250 repo: add a default output format to enum output_format
2:  0c7d3bca32 ! 2:  fba621fc4f repo: add new flag --keys to git-repo-info
    @@ Documentation/git-repo.adoc: SYNOPSIS
      --------
      [synopsis]
      git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
    -+git repo info --keys [--format=(default|nul) | -z]
    ++git repo info --keys [--format=(default|lines|nul) | -z]
      git repo structure [--format=(default|table|keyvalue|nul) | -z]
      
      DESCRIPTION
    @@ Documentation/git-repo.adoc: supported:
      +
      `-z` is an alias for `--format=nul`.
      
    -+`info --keys [--format=(default|nul) | -z]`::
    ++`info --keys [--format=(default|lines|nul) | -z]`::
     +	List all the available keys, one per line. The output format can be chosen
     +	through the flag `--format`. The following formats are supported:
     ++
     +`default`:::
    ++	synonym for `lines`.
    ++
    ++`lines`:::
     +	output the keys one per line.
     +
     +`nul`:::
    -+	similar to `default`, but using a NUL character after each value.
    ++	similar to `default`, but using a _NUL_ character after each value.
     +
      `structure [--format=(default|table|keyvalue|nul) | -z]`::
      	Retrieve statistics about the current repository structure. The
    @@ builtin/repo.c
      
      static const char *const repo_usage[] = {
      	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
    -+	"git repo info --keys [--format=(default|nul) | -z]",
    ++	"git repo info --keys [--format=(default|lines|nul) | -z]",
      	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
      	NULL
      };
    +@@ builtin/repo.c: enum output_format {
    + 	FORMAT_TABLE,
    + 	FORMAT_KEYVALUE,
    + 	FORMAT_NUL_TERMINATED,
    ++	FORMAT_LINES
    + };
    + 
    + struct field {
     @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      	return 0;
      }
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
     +{
     +	char sep;
     +
    ++	if (format == FORMAT_DEFAULT)
    ++		format = FORMAT_LINES;
    ++
     +	switch (format) {
    -+	case FORMAT_DEFAULT:
    ++	case FORMAT_LINES:
     +		sep = '\n';
     +		break;
     +	case FORMAT_NUL_TERMINATED:
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      static int parse_format_cb(const struct option *opt,
      			   const char *arg, int unset UNUSED)
      {
    +@@ builtin/repo.c: static int parse_format_cb(const struct option *opt,
    + 		*format = FORMAT_KEYVALUE;
    + 	else if (!strcmp(arg, "table"))
    + 		*format = FORMAT_TABLE;
    ++	else if (!strcmp(arg, "lines"))
    ++		*format = FORMAT_LINES;
    + 	else if (!strcmp(arg, "default"))
    + 		*format = FORMAT_DEFAULT;
    + 	else
     @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
      {
      	enum output_format format = FORMAT_DEFAULT;
    @@ t/t1900-repo.sh: test_expect_success '--format=default resets the format' '
     +	test_cmp expect actual_all &&
     +	test_cmp expect actual_key
     +'
    ++
    ++test_expect_success 'git repo info --keys uses lines as its default output format' '
    ++	git repo info --keys --format=lines >expect &&
    ++	git repo info --keys --format=default >actual_explicit &&
    ++	git repo info --keys >actual_implicit &&
    ++	test_cmp expect actual_explicit &&
    ++	test_cmp expect actual_implicit
    ++'
     +
      test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 1/2] repo: add a default output format to enum output_format
  2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
@ 2026-01-19 20:20   ` Lucas Seiki Oshiro
  2026-01-19 20:20   ` [PATCH v4 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2026-01-20  0:52   ` [PATCH v4 0/2] repo: add --format=default and --keys Junio C Hamano
  2 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-19 20:20 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

Add "default" as an option for --format in both git-repo-info and
git-repo-structure. Using `--format=default` makes those commands use
their default output format.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 19 ++++++++++++-------
 builtin/repo.c              | 18 ++++++++++++++----
 t/t1900-repo.sh             | 12 ++++++++++++
 t/t1901-repo-structure.sh   | 22 ++++++++++++++++++++++
 4 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 7d70270dfa..fa0e6600af 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
 SYNOPSIS
 --------
 [synopsis]
-git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul) | -z]
+git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
+git repo structure [--format=(default|table|keyvalue|nul) | -z]
 
 DESCRIPTION
 -----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
 
 COMMANDS
 --------
-`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
+`info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]`::
 	Retrieve metadata-related information about the current repository. Only
 	the requested data will be returned based on their keys (see "INFO KEYS"
 	section below).
@@ -30,11 +30,14 @@ requested. The `--all` flag requests the values for all the available keys.
 The output format can be chosen through the flag `--format`. Two formats are
 supported:
 +
+`default`:::
+	synonym for `keyvalue`.
+
 `keyvalue`:::
 	output key-value pairs one per line using the `=` character as
 	the delimiter between the key and the value. Values containing "unusual"
 	characters are quoted as explained for the configuration variable
-	`core.quotePath` (see linkgit:git-config[1]). This is the default.
+	`core.quotePath` (see linkgit:git-config[1]).
 
 `nul`:::
 	similar to `keyvalue`, but using a newline character as the delimiter
@@ -44,7 +47,7 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
-`structure [--format=(table|keyvalue|nul) | -z]`::
+`structure [--format=(default|table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
 +
@@ -56,10 +59,12 @@ supported:
 The output format can be chosen through the flag `--format`. Three formats are
 supported:
 +
+`default`:::
+	synonym for `table`.
+
 `table`:::
 	Outputs repository stats in a human-friendly table. This format may
-	change and is not intended for machine parsing. This is the default
-	format.
+	change and is not intended for machine parsing.
 
 `keyvalue`:::
 	Each line of output contains a key-value pair for a repository stat.
diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..306d3fa2df 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -17,14 +17,15 @@
 #include "utf8.h"
 
 static const char *const repo_usage[] = {
-	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
-	"git repo structure [--format=(table|keyvalue|nul) | -z]",
+	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
 	NULL
 };
 
 typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
+	FORMAT_DEFAULT,
 	FORMAT_TABLE,
 	FORMAT_KEYVALUE,
 	FORMAT_NUL_TERMINATED,
@@ -161,6 +162,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_KEYVALUE;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
+	else if (!strcmp(arg, "default"))
+		*format = FORMAT_DEFAULT;
 	else
 		die(_("invalid format '%s'"), arg);
 
@@ -170,7 +173,7 @@ static int parse_format_cb(const struct option *opt,
 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			 struct repository *repo)
 {
-	enum output_format format = FORMAT_KEYVALUE;
+	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -185,6 +188,10 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_KEYVALUE;
+
 	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
@@ -638,7 +645,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 	struct stats_table table = {
 		.rows = STRING_LIST_INIT_DUP,
 	};
-	enum output_format format = FORMAT_TABLE;
+	enum output_format format = FORMAT_DEFAULT;
 	struct repo_structure stats = { 0 };
 	struct rev_info revs;
 	int show_progress = -1;
@@ -658,6 +665,9 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 	if (argc)
 		usage(_("too many arguments"));
 
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_TABLE;
+
 	repo_init_revisions(repo, &revs, prefix);
 
 	if (show_progress < 0)
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..e6670f0f58 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -131,4 +131,16 @@ test_expect_success 'git repo info --all <key> aborts' '
 	test_cmp expect actual
 '
 
+test_expect_success '--format=default is a synonym for --format=keyvalue' '
+	git repo info --all --format=keyvalue >expect &&
+	git repo info --all --format=default >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success '--format=default resets the format' '
+	git repo info --all >expect &&
+	git repo info --all --format=nul --format=default >actual &&
+	test_cmp expect actual
+'
+
 test_done
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 17ff164b05..9c5054c8db 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -181,4 +181,26 @@ test_expect_success 'progress meter option' '
 	)
 '
 
+test_expect_success '--format=default is a synonym for --format=table' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git repo structure --format=table >expect &&
+		git repo structure --format=default >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success '--format=default resets the format' '
+	test_when_finished "rm -rf repo" &&
+	git init repo &&
+	(
+		cd repo &&
+		git repo structure >expect &&
+		git repo structure --format=nul --format=default >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 2/2] repo: add new flag --keys to git-repo-info
  2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
  2026-01-19 20:20   ` [PATCH v4 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
@ 2026-01-19 20:20   ` Lucas Seiki Oshiro
  2026-01-20  6:05     ` Patrick Steinhardt
  2026-01-20  0:52   ` [PATCH v4 0/2] repo: add --format=default and --keys Junio C Hamano
  2 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-19 20:20 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

If the user wants to find what are the available keys, they need to
either check the documentation or to ask for all the key-value pairs
by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 14 +++++++++++++
 builtin/repo.c              | 38 +++++++++++++++++++++++++++++++++
 t/t1900-repo.sh             | 42 +++++++++++++++++++++++++++----------
 3 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index fa0e6600af..2472345a7c 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
+git repo info --keys [--format=(default|lines|nul) | -z]
 git repo structure [--format=(default|table|keyvalue|nul) | -z]
 
 DESCRIPTION
@@ -47,6 +48,19 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys [--format=(default|lines|nul) | -z]`::
+	List all the available keys, one per line. The output format can be chosen
+	through the flag `--format`. The following formats are supported:
++
+`default`:::
+	synonym for `lines`.
+
+`lines`:::
+	output the keys one per line.
+
+`nul`:::
+	similar to `default`, but using a _NUL_ character after each value.
+
 `structure [--format=(default|table|keyvalue|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 306d3fa2df..2f698c5253 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -18,6 +18,7 @@
 
 static const char *const repo_usage[] = {
 	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
+	"git repo info --keys [--format=(default|lines|nul) | -z]",
 	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
 	NULL
 };
@@ -29,6 +30,7 @@ enum output_format {
 	FORMAT_TABLE,
 	FORMAT_KEYVALUE,
 	FORMAT_NUL_TERMINATED,
+	FORMAT_LINES
 };
 
 struct field {
@@ -149,6 +151,32 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(enum output_format format)
+{
+	char sep;
+
+	if (format == FORMAT_DEFAULT)
+		format = FORMAT_LINES;
+
+	switch (format) {
+	case FORMAT_LINES:
+		sep = '\n';
+		break;
+	case FORMAT_NUL_TERMINATED:
+		sep = '\0';
+		break;
+	default:
+		die(_("--keys can only be used with --format=default or --format=nul"));
+	}
+
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		printf("%s%c", field->key, sep);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -162,6 +190,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_KEYVALUE;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
+	else if (!strcmp(arg, "lines"))
+		*format = FORMAT_LINES;
 	else if (!strcmp(arg, "default"))
 		*format = FORMAT_DEFAULT;
 	else
@@ -175,6 +205,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_DEFAULT;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -184,11 +215,18 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
 
+	if (show_keys && (all_keys || argc))
+		die(_("--keys cannot be used with a <key> or --all"));
+
+	if (show_keys)
+		return print_keys(format);
+
 	if (format == FORMAT_DEFAULT)
 		format = FORMAT_KEYVALUE;
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index e6670f0f58..832938e958 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
@@ -143,4 +134,33 @@ test_expect_success '--format=default resets the format' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
+	git repo info --keys --format=default >default &&
+	lf_to_nul <default >expect &&
+	git repo info --keys --format=nul >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when using --format other than default or nul' '
+	echo "fatal: --keys can only be used with --format=default or --format=nul" >expect &&
+	test_must_fail git repo info --keys --format=keyvalue 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when requesting keys' '
+	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
+	test_must_fail git repo info --keys --all 2>actual_all &&
+	test_must_fail git repo info --keys some.key 2>actual_key &&
+	test_cmp expect actual_all &&
+	test_cmp expect actual_key
+'
+
+test_expect_success 'git repo info --keys uses lines as its default output format' '
+	git repo info --keys --format=lines >expect &&
+	git repo info --keys --format=default >actual_explicit &&
+	git repo info --keys >actual_implicit &&
+	test_cmp expect actual_explicit &&
+	test_cmp expect actual_implicit
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 0/2] repo: add --format=default and --keys
  2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
  2026-01-19 20:20   ` [PATCH v4 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
  2026-01-19 20:20   ` [PATCH v4 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-20  0:52   ` Junio C Hamano
  2 siblings, 0 replies; 40+ messages in thread
From: Junio C Hamano @ 2026-01-20  0:52 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, ps, jltobler, avila.jn

Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:

> Hello, again!
>
> This v4 addresses these two issues:
>
> 1. NUL was replaced by _NUL_ in the documentation
> 2. Now, the default output format of `git repo info --keys` is "lines"
>    and "default" is a synonym for it. I prefer to called it "lines"
>    instead of "newline" (as suggested by Patrick) because I thought that
>    it would be clear to the user

Sounds good.  It feels natural to ask for "newline-delimited" output
format by telling the tool "give me lines".


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 2/2] repo: add new flag --keys to git-repo-info
  2026-01-19 20:20   ` [PATCH v4 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-20  6:05     ` Patrick Steinhardt
  2026-01-20 23:11       ` Lucas Seiki Oshiro
  0 siblings, 1 reply; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-20  6:05 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler, avila.jn

On Mon, Jan 19, 2026 at 05:20:20PM -0300, Lucas Seiki Oshiro wrote:
> diff --git a/builtin/repo.c b/builtin/repo.c
> index 306d3fa2df..2f698c5253 100644
> --- a/builtin/repo.c
> +++ b/builtin/repo.c
> @@ -29,6 +30,7 @@ enum output_format {
>  	FORMAT_TABLE,
>  	FORMAT_KEYVALUE,
>  	FORMAT_NUL_TERMINATED,
> +	FORMAT_LINES
>  };
>  
>  struct field {

Tiny nit: we also tend to terminate the last enum value with a comma.
The reason here is that it makes it easier to add new values going
forward while only having to change one line.

> @@ -149,6 +151,32 @@ static int print_all_fields(struct repository *repo,
>  	return 0;
>  }
>  
> +static int print_keys(enum output_format format)
> +{
> +	char sep;
> +
> +	if (format == FORMAT_DEFAULT)
> +		format = FORMAT_LINES;
> +
> +	switch (format) {
> +	case FORMAT_LINES:
> +		sep = '\n';
> +		break;
> +	case FORMAT_NUL_TERMINATED:
> +		sep = '\0';
> +		break;
> +	default:
> +		die(_("--keys can only be used with --format=default or --format=nul"));

This error message isn't true anymore, as we also support
"--format=lines" now.

> @@ -162,6 +190,8 @@ static int parse_format_cb(const struct option *opt,
>  		*format = FORMAT_KEYVALUE;
>  	else if (!strcmp(arg, "table"))
>  		*format = FORMAT_TABLE;
> +	else if (!strcmp(arg, "lines"))
> +		*format = FORMAT_LINES;
>  	else if (!strcmp(arg, "default"))
>  		*format = FORMAT_DEFAULT;
>  	else

You also have to adapt `cmd_repo_structure()` to handle this new vaule.
Otherwise it would `BUG()`. I guess the most reasonable change here
would be to treat "lines" and "keyvalue" as equivalent?

Thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 2/2] repo: add new flag --keys to git-repo-info
  2026-01-20  6:05     ` Patrick Steinhardt
@ 2026-01-20 23:11       ` Lucas Seiki Oshiro
  2026-01-21  7:19         ` Patrick Steinhardt
  0 siblings, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-20 23:11 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git, gitster, jltobler, avila.jn


> Tiny nit: we also tend to terminate the last enum value with a comma.
> The reason here is that it makes it easier to add new values going
> forward while only having to change one line.

Sure, I forgot to add it. 

> You also have to adapt `cmd_repo_structure()` to handle this new vaule.
> Otherwise it would `BUG()`. I guess the most reasonable change here
> would be to treat "lines" and "keyvalue" as equivalent?

Nice catch! I don't know if it makes sense. If we change that in
structure, we'll also need to also change in info, making the name
"keyvalue" useless. Another solution: change the current "keyvalues" by
"lines" in those three cases. Maybe it makes more sense than the name
"keyvalue".

> Thanks!

Thanks again, Patrick!


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 2/2] repo: add new flag --keys to git-repo-info
  2026-01-20 23:11       ` Lucas Seiki Oshiro
@ 2026-01-21  7:19         ` Patrick Steinhardt
  2026-01-21 14:38           ` Lucas Seiki Oshiro
  0 siblings, 1 reply; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-21  7:19 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler, avila.jn

On Tue, Jan 20, 2026 at 08:11:35PM -0300, Lucas Seiki Oshiro wrote:
> 
> > Tiny nit: we also tend to terminate the last enum value with a comma.
> > The reason here is that it makes it easier to add new values going
> > forward while only having to change one line.
> 
> Sure, I forgot to add it. 
> 
> > You also have to adapt `cmd_repo_structure()` to handle this new vaule.
> > Otherwise it would `BUG()`. I guess the most reasonable change here
> > would be to treat "lines" and "keyvalue" as equivalent?
> 
> Nice catch! I don't know if it makes sense. If we change that in
> structure, we'll also need to also change in info, making the name
> "keyvalue" useless. Another solution: change the current "keyvalues" by
> "lines" in those three cases. Maybe it makes more sense than the name
> "keyvalue".

I also thought about it, but didn't want to propose it myself. But I
agree that this would be a reasonable change. After all, git-repo(1) is
still young and it's marked as experimental, so from my perspective it
is fair to do adjustments like this once we notice that we've been a bit
too narrow-minded.

So I'm all for it.

Thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 2/2] repo: add new flag --keys to git-repo-info
  2026-01-21  7:19         ` Patrick Steinhardt
@ 2026-01-21 14:38           ` Lucas Seiki Oshiro
  0 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-21 14:38 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git, gitster, jltobler, avila.jn


> I also thought about it, but didn't want to propose it myself. But I
> agree that this would be a reasonable change. After all, git-repo(1) is
> still young and it's marked as experimental, so from my perspective it
> is fair to do adjustments like this once we notice that we've been a bit
> too narrow-minded.
> 
> So I'm all for it.

Agreed. And I think that it makes more sense than adding a new output
format only for --keys and extra checks in other places.

Besides this, I sent first patch of this series (the "default" output
format) to support -z with --keys [1]. If we change "keyvalue" to
"lines" maybe it wouldn't be useful.

So, now I'm thinking about dropping the first patch and replacing it 
by a new one renaming "keyvalue" to "lines".


[1] https://lore.kernel.org/git/5A4D4433-FD38-4BB0-81B6-3BAD33A30A74@gmail.com/

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines"
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (6 preceding siblings ...)
  2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
@ 2026-01-23 16:34 ` Lucas Seiki Oshiro
  2026-01-23 16:34   ` [PATCH v5 1/2] repo: " Lucas Seiki Oshiro
  2026-01-23 16:34   ` [PATCH v5 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  8 siblings, 2 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-23 16:34 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

Hi!

There are two main changes in this v5:

- the "keyvalue" output format of git-repo-info and git-repo-structure were
  both renamed by "lines"
- the "default" output format was dropped

This way:

- `git repo info` accepts --format=lines and --format=nul
- `git repo info --keys` accepts --format=lines and --format=nul
- `git repo structure` accepts --format=table, --format=lines and --format=nul

Lucas Seiki Oshiro (2):
  repo: rename "keyvalue" to "lines"
  repo: add new flag --keys to git-repo-info

 Documentation/git-repo.adoc | 32 +++++++++++++++--------
 builtin/repo.c              | 51 ++++++++++++++++++++++++++++++-------
 t/t1900-repo.sh             | 44 ++++++++++++++++++++++----------
 t/t1901-repo-structure.sh   |  4 +--
 4 files changed, 97 insertions(+), 34 deletions(-)

Range-diff against v4:
1:  7dabd62250 < -:  ---------- repo: add a default output format to enum output_format
-:  ---------- > 1:  f5448ce915 repo: rename "keyvalue" to "lines"
2:  fba621fc4f ! 2:  16bc72afe1 repo: add new flag --keys to git-repo-info
    @@ Documentation/git-repo.adoc
     @@ Documentation/git-repo.adoc: SYNOPSIS
      --------
      [synopsis]
    - git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]
    -+git repo info --keys [--format=(default|lines|nul) | -z]
    - git repo structure [--format=(default|table|keyvalue|nul) | -z]
    + 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]

      DESCRIPTION
     @@ Documentation/git-repo.adoc: supported:
      +
      `-z` is an alias for `--format=nul`.

    -+`info --keys [--format=(default|lines|nul) | -z]`::
    ++`info --keys [--format=(lines|nul) | -z]`::
     +	List all the available keys, one per line. The output format can be chosen
     +	through the flag `--format`. The following formats are supported:
     ++
    -+`default`:::
    -+	synonym for `lines`.
    -+
     +`lines`:::
    -+	output the keys one per line.
    ++	output the keys one per line. This is the default.
     +
     +`nul`:::
    -+	similar to `default`, but using a _NUL_ character after each value.
    ++	similar to `lines`, but using a _NUL_ character after each value.
     +
    - `structure [--format=(default|table|keyvalue|nul) | -z]`::
    + `structure [--format=(table|lines|nul) | -z]`::
      	Retrieve statistics about the current repository structure. The
      	following kinds of information are reported:

    @@ builtin/repo.c
     @@

      static const char *const repo_usage[] = {
    - 	"git repo info [--format=(default|keyvalue|nul) | -z] [--all | <key>...]",
    -+	"git repo info --keys [--format=(default|lines|nul) | -z]",
    - 	"git repo structure [--format=(default|table|keyvalue|nul) | -z]",
    + 	"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
      };
    -@@ builtin/repo.c: enum output_format {
    - 	FORMAT_TABLE,
    - 	FORMAT_KEYVALUE,
    - 	FORMAT_NUL_TERMINATED,
    -+	FORMAT_LINES
    - };
    -
    - struct field {
     @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      	return 0;
      }
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
     +{
     +	char sep;
     +
    -+	if (format == FORMAT_DEFAULT)
    -+		format = FORMAT_LINES;
    -+
     +	switch (format) {
     +	case FORMAT_LINES:
     +		sep = '\n';
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
     +		sep = '\0';
     +		break;
     +	default:
    -+		die(_("--keys can only be used with --format=default or --format=nul"));
    ++		die(_("--keys can only be used with --format=lines or --format=nul"));
     +	}
     +
     +	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      static int parse_format_cb(const struct option *opt,
      			   const char *arg, int unset UNUSED)
      {
    -@@ builtin/repo.c: static int parse_format_cb(const struct option *opt,
    - 		*format = FORMAT_KEYVALUE;
    - 	else if (!strcmp(arg, "table"))
    - 		*format = FORMAT_TABLE;
    -+	else if (!strcmp(arg, "lines"))
    -+		*format = FORMAT_LINES;
    - 	else if (!strcmp(arg, "default"))
    - 		*format = FORMAT_DEFAULT;
    - 	else
     @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
      {
    - 	enum output_format format = FORMAT_DEFAULT;
    + 	enum output_format format = FORMAT_LINES;
      	int all_keys = 0;
     +	int show_keys = 0;
      	struct option options[] = {
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
     +	if (show_keys)
     +		return print_keys(format);
     +
    - 	if (format == FORMAT_DEFAULT)
    - 		format = FORMAT_KEYVALUE;
    + 	if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
    + 		die(_("unsupported output format"));


      ## t/t1900-repo.sh ##
    @@ t/t1900-repo.sh: test_expect_success 'git repo info uses the last requested form
      	git repo info --all >actual &&
      	test_cmp expect actual
      '
    -@@ t/t1900-repo.sh: test_expect_success '--format=default resets the format' '
    +@@ t/t1900-repo.sh: test_expect_success 'git repo info --all <key> aborts' '
      	test_cmp expect actual
      '

     +test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
    -+	git repo info --keys --format=default >default &&
    -+	lf_to_nul <default >expect &&
    ++	git repo info --keys --format=lines >lines &&
    ++	lf_to_nul <lines >expect &&
     +	git repo info --keys --format=nul >actual &&
     +	test_cmp expect actual
     +'
     +
    -+test_expect_success 'git repo info --keys aborts when using --format other than default or nul' '
    -+	echo "fatal: --keys can only be used with --format=default or --format=nul" >expect &&
    -+	test_must_fail git repo info --keys --format=keyvalue 2>actual &&
    ++test_expect_success 'git repo info --keys aborts when using --format other than lines or nul' '
    ++	echo "fatal: --keys can only be used with --format=lines or --format=nul" >expect &&
    ++	test_must_fail git repo info --keys --format=table 2>actual &&
     +	test_cmp expect actual
     +'
     +
    @@ t/t1900-repo.sh: test_expect_success '--format=default resets the format' '
     +
     +test_expect_success 'git repo info --keys uses lines as its default output format' '
     +	git repo info --keys --format=lines >expect &&
    -+	git repo info --keys --format=default >actual_explicit &&
    -+	git repo info --keys >actual_implicit &&
    -+	test_cmp expect actual_explicit &&
    -+	test_cmp expect actual_implicit
    ++	git repo info --keys >actual &&
    ++	test_cmp expect actual
     +'
     +
      test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v5 1/2] repo: rename "keyvalue" to "lines"
  2026-01-23 16:34 ` [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
@ 2026-01-23 16:34   ` Lucas Seiki Oshiro
  2026-01-27  6:58     ` Patrick Steinhardt
  2026-01-23 16:34   ` [PATCH v5 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  1 sibling, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-23 16:34 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

The output format name "keyvalue" isn't so descriptive. Rename it to
"lines", since it describes better the syntax of the output format and
it isn't tied to key-value pairs.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 21 +++++++++++----------
 builtin/repo.c              | 19 ++++++++++---------
 t/t1900-repo.sh             |  4 ++--
 t/t1901-repo-structure.sh   |  4 ++--
 4 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 7d70270dfa..693e1bbced 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
 SYNOPSIS
 --------
 [synopsis]
-git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul) | -z]
+git repo info [--format=(lines|nul) | -z] [--all | <key>...]
+git repo structure [--format=(table|lines|nul) | -z]
 
 DESCRIPTION
 -----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
 
 COMMANDS
 --------
-`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
+`info [--format=(lines|nul) | -z] [--all | <key>...]`::
 	Retrieve metadata-related information about the current repository. Only
 	the requested data will be returned based on their keys (see "INFO KEYS"
 	section below).
@@ -30,21 +30,22 @@ requested. The `--all` flag requests the values for all the available keys.
 The output format can be chosen through the flag `--format`. Two formats are
 supported:
 +
-`keyvalue`:::
+
+`lines`:::
 	output key-value pairs one per line using the `=` character as
 	the delimiter between the key and the value. Values containing "unusual"
 	characters are quoted as explained for the configuration variable
 	`core.quotePath` (see linkgit:git-config[1]). This is the default.
 
 `nul`:::
-	similar to `keyvalue`, but using a newline character as the delimiter
+	similar to `lines`, but using a newline character as the delimiter
 	between the key and the value and using a NUL character after each value.
 	This format is better suited for being parsed by another applications than
-	`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.
+	`lines`. Unlike in the `lines` format, the values are never quoted.
 +
 `-z` is an alias for `--format=nul`.
 
-`structure [--format=(table|keyvalue|nul) | -z]`::
+`structure [--format=(table|lines|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
 +
@@ -61,17 +62,17 @@ supported:
 	change and is not intended for machine parsing. This is the default
 	format.
 
-`keyvalue`:::
+`lines`:::
 	Each line of output contains a key-value pair for a repository stat.
 	The '=' character is used to delimit between the key and the value.
 	Values containing "unusual" characters are quoted as explained for the
 	configuration variable `core.quotePath` (see linkgit:git-config[1]).
 
 `nul`:::
-	Similar to `keyvalue`, but uses a NUL character to delimit between
+	Similar to `lines`, but uses a NUL character to delimit between
 	key-value pairs instead of a newline. Also uses a newline character as
 	the delimiter between the key and value instead of '='. Unlike the
-	`keyvalue` format, values containing "unusual" characters are never
+	`lines` format, values containing "unusual" characters are never
 	quoted.
 +
 `-z` is an alias for `--format=nul`.
diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..4031612bc8 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -17,8 +17,8 @@
 #include "utf8.h"
 
 static const char *const repo_usage[] = {
-	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
-	"git repo structure [--format=(table|keyvalue|nul) | -z]",
+	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
+	"git repo structure [--format=(table|lines|nul) | -z]",
 	NULL
 };
 
@@ -26,7 +26,7 @@ typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
 	FORMAT_TABLE,
-	FORMAT_KEYVALUE,
+	FORMAT_LINES,
 	FORMAT_NUL_TERMINATED,
 };
 
@@ -91,7 +91,7 @@ static void print_field(enum output_format format, const char *key,
 			const char *value)
 {
 	switch (format) {
-	case FORMAT_KEYVALUE:
+	case FORMAT_LINES:
 		printf("%s=", key);
 		quote_c_style(value, NULL, stdout, 0);
 		putchar('\n');
@@ -157,8 +157,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_NUL_TERMINATED;
 	else if (!strcmp(arg, "nul"))
 		*format = FORMAT_NUL_TERMINATED;
-	else if (!strcmp(arg, "keyvalue"))
-		*format = FORMAT_KEYVALUE;
+	else if (!strcmp(arg, "lines"))
+		*format = FORMAT_LINES;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
 	else
@@ -170,7 +170,7 @@ static int parse_format_cb(const struct option *opt,
 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			 struct repository *repo)
 {
-	enum output_format format = FORMAT_KEYVALUE;
+	enum output_format format = FORMAT_LINES;
 	int all_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -185,7 +185,8 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
-	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
+
+	if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
 	if (all_keys && argc)
@@ -671,7 +672,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 		stats_table_setup_structure(&table, &stats);
 		stats_table_print_structure(&table);
 		break;
-	case FORMAT_KEYVALUE:
+	case FORMAT_LINES:
 		structure_keyvalue_print(&stats, '=', '\n');
 		break;
 	case FORMAT_NUL_TERMINATED:
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..4155211e5d 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -34,7 +34,7 @@ test_repo_info () {
 		eval "$init_command $repo_name"
 	'
 
-	test_expect_success "keyvalue: $label" '
+	test_expect_success "lines: $label" '
 		echo "$key=$expected_value" > expect &&
 		git -C "$repo_name" repo info "$key" >actual &&
 		test_cmp expect actual
@@ -115,7 +115,7 @@ test_expect_success '-z uses nul-terminated format' '
 
 test_expect_success 'git repo info uses the last requested format' '
 	echo "layout.bare=false" >expected &&
-	git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
+	git repo info --format=nul -z --format=lines layout.bare >actual &&
 	test_cmp expected actual
 '
 
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 17ff164b05..a6f2591d9a 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -113,7 +113,7 @@ test_expect_success SHA1 'repository with references and objects' '
 	)
 '
 
-test_expect_success SHA1 'keyvalue and nul format' '
+test_expect_success SHA1 'lines and nul format' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
 	(
@@ -140,7 +140,7 @@ test_expect_success SHA1 'keyvalue and nul format' '
 		objects.tags.disk_size=$(object_type_disk_usage tag)
 		EOF
 
-		git repo structure --format=keyvalue >out 2>err &&
+		git repo structure --format=lines >out 2>err &&
 
 		test_cmp expect out &&
 		test_line_count = 0 err &&
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v5 2/2] repo: add new flag --keys to git-repo-info
  2026-01-23 16:34 ` [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  2026-01-23 16:34   ` [PATCH v5 1/2] repo: " Lucas Seiki Oshiro
@ 2026-01-23 16:34   ` Lucas Seiki Oshiro
  2026-01-27  6:58     ` Patrick Steinhardt
  1 sibling, 1 reply; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-23 16:34 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

If the user wants to find what are the available keys, they need to
either check the documentation or to ask for all the key-value pairs
by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 11 ++++++++++
 builtin/repo.c              | 32 +++++++++++++++++++++++++++++
 t/t1900-repo.sh             | 40 +++++++++++++++++++++++++++----------
 3 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 693e1bbced..f474274009 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 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]
 
 DESCRIPTION
@@ -45,6 +46,16 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys [--format=(lines|nul) | -z]`::
+	List all the available keys, one per line. The output format can be chosen
+	through the flag `--format`. The following formats are supported:
++
+`lines`:::
+	output the keys one per line. This is the default.
+
+`nul`:::
+	similar to `lines`, but using a _NUL_ character after each value.
+
 `structure [--format=(table|lines|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 4031612bc8..a7d4855f06 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -18,6 +18,7 @@
 
 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
 };
@@ -148,6 +149,29 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(enum output_format format)
+{
+	char sep;
+
+	switch (format) {
+	case FORMAT_LINES:
+		sep = '\n';
+		break;
+	case FORMAT_NUL_TERMINATED:
+		sep = '\0';
+		break;
+	default:
+		die(_("--keys can only be used with --format=lines or --format=nul"));
+	}
+
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		printf("%s%c", field->key, sep);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -172,6 +196,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_LINES;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -181,11 +206,18 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
 
+	if (show_keys && (all_keys || argc))
+		die(_("--keys cannot be used with a <key> or --all"));
+
+	if (show_keys)
+		return print_keys(format);
+
 	if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 4155211e5d..a9eb07abe8 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
@@ -131,4 +122,31 @@ test_expect_success 'git repo info --all <key> aborts' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
+	git repo info --keys --format=lines >lines &&
+	lf_to_nul <lines >expect &&
+	git repo info --keys --format=nul >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when using --format other than lines or nul' '
+	echo "fatal: --keys can only be used with --format=lines or --format=nul" >expect &&
+	test_must_fail git repo info --keys --format=table 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when requesting keys' '
+	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
+	test_must_fail git repo info --keys --all 2>actual_all &&
+	test_must_fail git repo info --keys some.key 2>actual_key &&
+	test_cmp expect actual_all &&
+	test_cmp expect actual_key
+'
+
+test_expect_success 'git repo info --keys uses lines as its default output format' '
+	git repo info --keys --format=lines >expect &&
+	git repo info --keys >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v5 1/2] repo: rename "keyvalue" to "lines"
  2026-01-23 16:34   ` [PATCH v5 1/2] repo: " Lucas Seiki Oshiro
@ 2026-01-27  6:58     ` Patrick Steinhardt
  0 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-27  6:58 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler, avila.jn

On Fri, Jan 23, 2026 at 01:34:53PM -0300, Lucas Seiki Oshiro wrote:
> The output format name "keyvalue" isn't so descriptive. Rename it to
> "lines", since it describes better the syntax of the output format and
> it isn't tied to key-value pairs.

I think this commit message is a bit hand-wavy. Most importantly, the
reader might wonder _why_ it isn't so descriptive, and why these
concerns are strong enough to change the accepted value now.

I would've written something like the following:

    Both subcommands in git-repo(1) accept the "keyvalue" format. This
    format is newline-delimited, where the key is separated from the
    value with an equals sign.

    The name of this option is suboptimal though, as it is both too
    limiting while at the same time not really indicating what it
    actually does:

      - There is no mention of the format being newline-delimited, which
        is the key differentiator to the "nul" format.

      - Both "nul" and "keyvalue" have a key and a value, so the latter
        is not exactly giving any hint what makes it so special.

      - "keyvalue" requires there to be, well, a key and a value, but we
        want to add additional output that is only going to be newline
        delimited.

    Taken together, "keyvalue" is kind of a bad name for this output
    format.

    Luckily, the git-repo(1) command is still rather new and marked as
    experimental, so things aren't cast into stone yet. Rename the
    format to "lines" instead to better indicate that the major
    difference is that we'll get newline-delimited output. This new name
    will also be a better fit for a subsequent extension in git-repo(1).

Please feel free to use this message or parts of it if you plan to
reroll.

I was also briefly wondering whether it would make sense to call the new
format "newlines" instead of "lines", but I'm not feeling strongly about
this in any way.

> diff --git a/builtin/repo.c b/builtin/repo.c
> index 0ea045abc1..4031612bc8 100644
> --- a/builtin/repo.c
> +++ b/builtin/repo.c
> @@ -26,7 +26,7 @@ typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
>  
>  enum output_format {
>  	FORMAT_TABLE,
> -	FORMAT_KEYVALUE,
> +	FORMAT_LINES,
>  	FORMAT_NUL_TERMINATED,
>  };

This feels a bit unbalanced to me, as `FORMAT_LINES` and
`FORMAT_NUL_TERMINATED` look so different from one another. Maybe it
would be better to call it `FORMAT_NEWLINE_TERMINATED`?

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v5 2/2] repo: add new flag --keys to git-repo-info
  2026-01-23 16:34   ` [PATCH v5 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-01-27  6:58     ` Patrick Steinhardt
  2026-01-27 22:27       ` Lucas Seiki Oshiro
  0 siblings, 1 reply; 40+ messages in thread
From: Patrick Steinhardt @ 2026-01-27  6:58 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler, avila.jn

On Fri, Jan 23, 2026 at 01:34:54PM -0300, Lucas Seiki Oshiro wrote:
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index 693e1bbced..f474274009 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -45,6 +46,16 @@ supported:
>  +
>  `-z` is an alias for `--format=nul`.
>  
> +`info --keys [--format=(lines|nul) | -z]`::
> +	List all the available keys, one per line. The output format can be chosen
> +	through the flag `--format`. The following formats are supported:
> ++
> +`lines`:::
> +	output the keys one per line. This is the default.
> +
> +`nul`:::
> +	similar to `lines`, but using a _NUL_ character after each value.

Shouldn' these sentences start with an upper-case character? I see that
we don't do it either for the existing docs, but it reads a bit weird to
me.

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v5 2/2] repo: add new flag --keys to git-repo-info
  2026-01-27  6:58     ` Patrick Steinhardt
@ 2026-01-27 22:27       ` Lucas Seiki Oshiro
  0 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-01-27 22:27 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git, gitster, jltobler, avila.jn


>> 
>> +`info --keys [--format=(lines|nul) | -z]`::
>> + List all the available keys, one per line. The output format can be chosen
>> + through the flag `--format`. The following formats are supported:
>> ++
>> +`lines`:::
>> + output the keys one per line. This is the default.
>> +
>> +`nul`:::
>> + similar to `lines`, but using a _NUL_ character after each value.
> 
> Shouldn' these sentences start with an upper-case character? I see that
> we don't do it either for the existing docs, but it reads a bit weird to
> me.

Ok, I'll fix it.

Btw, I'm collecting those nitpicks about the existing code and I'll send
a patch series fixing them after finishing this :-)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines"
  2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
                   ` (7 preceding siblings ...)
  2026-01-23 16:34 ` [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
@ 2026-02-14  0:35 ` Lucas Seiki Oshiro
  2026-02-14  0:35   ` [PATCH v6 1/2] repo: rename the output format " Lucas Seiki Oshiro
                     ` (2 more replies)
  8 siblings, 3 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-02-14  0:35 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

Hi!

This v6 addresses these issues raised by Patrick:

- It renames `FORMAT_LINES` to `FORMAT_NEWLINE_TERMINATED`
- Change the commit messsage of the first patch (I'm using Patrick's
  suggestion)
- It capitalizes the new paragraphs

There was a discussion about the name of the new format ("lines" vs
"newline") [1]. Personally I prefer "lines" instead of "newline" because
I understand the --format flag expects a format name (e.g. `table`,
`lines`) instead of the delimiter, being `nul` only a short form of
"nul-terminated". But, of course, I'm open to other opinions about it
:-).

Thanks

[1] aXhiHAFNFxgsXa0S@pks.im

Lucas Seiki Oshiro (2):
  repo: rename the output format "keyvalue" to "lines"
  repo: add new flag --keys to git-repo-info

 Documentation/git-repo.adoc | 32 +++++++++++++++--------
 builtin/repo.c              | 51 ++++++++++++++++++++++++++++++-------
 t/t1900-repo.sh             | 44 ++++++++++++++++++++++----------
 t/t1901-repo-structure.sh   |  4 +--
 4 files changed, 97 insertions(+), 34 deletions(-)

Range-diff against v5:
1:  f5448ce915 ! 1:  6f5b4a577e repo: rename "keyvalue" to "lines"
    @@ Metadata
     Author: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
     
      ## Commit message ##
    -    repo: rename "keyvalue" to "lines"
    +    repo: rename the output format "keyvalue" to "lines"
     
    -    The output format name "keyvalue" isn't so descriptive. Rename it to
    -    "lines", since it describes better the syntax of the output format and
    -    it isn't tied to key-value pairs.
    +    Both subcommands in git-repo(1) accept the "keyvalue" format. This
    +    format is newline-delimited, where the key is separated from the
    +    value with an equals sign.
     
    +    The name of this option is suboptimal though, as it is both too
    +    limiting while at the same time not really indicating what it
    +    actually does:
    +
    +      - There is no mention of the format being newline-delimited, which
    +        is the key differentiator to the "nul" format.
    +
    +      - Both "nul" and "keyvalue" have a key and a value, so the latter
    +        is not exactly giving any hint what makes it so special.
    +
    +      - "keyvalue" requires there to be, well, a key and a value, but we
    +        want to add additional output that is only going to be newline
    +        delimited.
    +
    +    Taken together, "keyvalue" is kind of a bad name for this output
    +    format.
    +
    +    Luckily, the git-repo(1) command is still rather new and marked as
    +    experimental, so things aren't cast into stone yet. Rename the
    +    format to "lines" instead to better indicate that the major
    +    difference is that we'll get newline-delimited output. This new name
    +    will also be a better fit for a subsequent extension in git-repo(1).
    +
    +    Helped-by: Patrick Steinhardt <ps@pks.im>
         Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
     
      ## Documentation/git-repo.adoc ##
    @@ builtin/repo.c: typedef int get_value_fn(struct repository *repo, struct strbuf
      enum output_format {
      	FORMAT_TABLE,
     -	FORMAT_KEYVALUE,
    -+	FORMAT_LINES,
    ++	FORMAT_NEWLINE_TERMINATED,
      	FORMAT_NUL_TERMINATED,
      };
      
    @@ builtin/repo.c: static void print_field(enum output_format format, const char *k
      {
      	switch (format) {
     -	case FORMAT_KEYVALUE:
    -+	case FORMAT_LINES:
    ++	case FORMAT_NEWLINE_TERMINATED:
      		printf("%s=", key);
      		quote_c_style(value, NULL, stdout, 0);
      		putchar('\n');
    @@ builtin/repo.c: static int parse_format_cb(const struct option *opt,
     -	else if (!strcmp(arg, "keyvalue"))
     -		*format = FORMAT_KEYVALUE;
     +	else if (!strcmp(arg, "lines"))
    -+		*format = FORMAT_LINES;
    ++		*format = FORMAT_NEWLINE_TERMINATED;
      	else if (!strcmp(arg, "table"))
      		*format = FORMAT_TABLE;
      	else
    @@ builtin/repo.c: static int parse_format_cb(const struct option *opt,
      			 struct repository *repo)
      {
     -	enum output_format format = FORMAT_KEYVALUE;
    -+	enum output_format format = FORMAT_LINES;
    ++	enum output_format format = FORMAT_NEWLINE_TERMINATED;
      	int all_keys = 0;
      	struct option options[] = {
      		OPT_CALLBACK_F(0, "format", &format, N_("format"),
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
      	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
     -	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
     +
    -+	if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
    ++	if (format != FORMAT_NEWLINE_TERMINATED && format != FORMAT_NUL_TERMINATED)
      		die(_("unsupported output format"));
      
      	if (all_keys && argc)
    @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const
      		stats_table_print_structure(&table);
      		break;
     -	case FORMAT_KEYVALUE:
    -+	case FORMAT_LINES:
    ++	case FORMAT_NEWLINE_TERMINATED:
      		structure_keyvalue_print(&stats, '=', '\n');
      		break;
      	case FORMAT_NUL_TERMINATED:
2:  16bc72afe1 ! 2:  53503e1433 repo: add new flag --keys to git-repo-info
    @@ Documentation/git-repo.adoc: supported:
     +	through the flag `--format`. The following formats are supported:
     ++
     +`lines`:::
    -+	output the keys one per line. This is the default.
    ++	Output the keys one per line. This is the default.
     +
     +`nul`:::
    -+	similar to `lines`, but using a _NUL_ character after each value.
    ++	Similar to `lines`, but using a _NUL_ character after each value.
     +
      `structure [--format=(table|lines|nul) | -z]`::
      	Retrieve statistics about the current repository structure. The
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
     +	char sep;
     +
     +	switch (format) {
    -+	case FORMAT_LINES:
    ++	case FORMAT_NEWLINE_TERMINATED:
     +		sep = '\n';
     +		break;
     +	case FORMAT_NUL_TERMINATED:
    @@ builtin/repo.c: static int print_all_fields(struct repository *repo,
      {
     @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
      {
    - 	enum output_format format = FORMAT_LINES;
    + 	enum output_format format = FORMAT_NEWLINE_TERMINATED;
      	int all_keys = 0;
     +	int show_keys = 0;
      	struct option options[] = {
    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char
     +	if (show_keys)
     +		return print_keys(format);
     +
    - 	if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
    + 	if (format != FORMAT_NEWLINE_TERMINATED && format != FORMAT_NUL_TERMINATED)
      		die(_("unsupported output format"));
      
     
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v6 1/2] repo: rename the output format "keyvalue" to "lines"
  2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
@ 2026-02-14  0:35   ` Lucas Seiki Oshiro
  2026-02-14  0:35   ` [PATCH v6 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
  2026-02-14 18:14   ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Junio C Hamano
  2 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-02-14  0:35 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

Both subcommands in git-repo(1) accept the "keyvalue" format. This
format is newline-delimited, where the key is separated from the
value with an equals sign.

The name of this option is suboptimal though, as it is both too
limiting while at the same time not really indicating what it
actually does:

  - There is no mention of the format being newline-delimited, which
    is the key differentiator to the "nul" format.

  - Both "nul" and "keyvalue" have a key and a value, so the latter
    is not exactly giving any hint what makes it so special.

  - "keyvalue" requires there to be, well, a key and a value, but we
    want to add additional output that is only going to be newline
    delimited.

Taken together, "keyvalue" is kind of a bad name for this output
format.

Luckily, the git-repo(1) command is still rather new and marked as
experimental, so things aren't cast into stone yet. Rename the
format to "lines" instead to better indicate that the major
difference is that we'll get newline-delimited output. This new name
will also be a better fit for a subsequent extension in git-repo(1).

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 21 +++++++++++----------
 builtin/repo.c              | 19 ++++++++++---------
 t/t1900-repo.sh             |  4 ++--
 t/t1901-repo-structure.sh   |  4 ++--
 4 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 7d70270dfa..693e1bbced 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
 SYNOPSIS
 --------
 [synopsis]
-git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul) | -z]
+git repo info [--format=(lines|nul) | -z] [--all | <key>...]
+git repo structure [--format=(table|lines|nul) | -z]
 
 DESCRIPTION
 -----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
 
 COMMANDS
 --------
-`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
+`info [--format=(lines|nul) | -z] [--all | <key>...]`::
 	Retrieve metadata-related information about the current repository. Only
 	the requested data will be returned based on their keys (see "INFO KEYS"
 	section below).
@@ -30,21 +30,22 @@ requested. The `--all` flag requests the values for all the available keys.
 The output format can be chosen through the flag `--format`. Two formats are
 supported:
 +
-`keyvalue`:::
+
+`lines`:::
 	output key-value pairs one per line using the `=` character as
 	the delimiter between the key and the value. Values containing "unusual"
 	characters are quoted as explained for the configuration variable
 	`core.quotePath` (see linkgit:git-config[1]). This is the default.
 
 `nul`:::
-	similar to `keyvalue`, but using a newline character as the delimiter
+	similar to `lines`, but using a newline character as the delimiter
 	between the key and the value and using a NUL character after each value.
 	This format is better suited for being parsed by another applications than
-	`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.
+	`lines`. Unlike in the `lines` format, the values are never quoted.
 +
 `-z` is an alias for `--format=nul`.
 
-`structure [--format=(table|keyvalue|nul) | -z]`::
+`structure [--format=(table|lines|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
 +
@@ -61,17 +62,17 @@ supported:
 	change and is not intended for machine parsing. This is the default
 	format.
 
-`keyvalue`:::
+`lines`:::
 	Each line of output contains a key-value pair for a repository stat.
 	The '=' character is used to delimit between the key and the value.
 	Values containing "unusual" characters are quoted as explained for the
 	configuration variable `core.quotePath` (see linkgit:git-config[1]).
 
 `nul`:::
-	Similar to `keyvalue`, but uses a NUL character to delimit between
+	Similar to `lines`, but uses a NUL character to delimit between
 	key-value pairs instead of a newline. Also uses a newline character as
 	the delimiter between the key and value instead of '='. Unlike the
-	`keyvalue` format, values containing "unusual" characters are never
+	`lines` format, values containing "unusual" characters are never
 	quoted.
 +
 `-z` is an alias for `--format=nul`.
diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..23c5ee88b0 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -17,8 +17,8 @@
 #include "utf8.h"
 
 static const char *const repo_usage[] = {
-	"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
-	"git repo structure [--format=(table|keyvalue|nul) | -z]",
+	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
+	"git repo structure [--format=(table|lines|nul) | -z]",
 	NULL
 };
 
@@ -26,7 +26,7 @@ typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
 
 enum output_format {
 	FORMAT_TABLE,
-	FORMAT_KEYVALUE,
+	FORMAT_NEWLINE_TERMINATED,
 	FORMAT_NUL_TERMINATED,
 };
 
@@ -91,7 +91,7 @@ static void print_field(enum output_format format, const char *key,
 			const char *value)
 {
 	switch (format) {
-	case FORMAT_KEYVALUE:
+	case FORMAT_NEWLINE_TERMINATED:
 		printf("%s=", key);
 		quote_c_style(value, NULL, stdout, 0);
 		putchar('\n');
@@ -157,8 +157,8 @@ static int parse_format_cb(const struct option *opt,
 		*format = FORMAT_NUL_TERMINATED;
 	else if (!strcmp(arg, "nul"))
 		*format = FORMAT_NUL_TERMINATED;
-	else if (!strcmp(arg, "keyvalue"))
-		*format = FORMAT_KEYVALUE;
+	else if (!strcmp(arg, "lines"))
+		*format = FORMAT_NEWLINE_TERMINATED;
 	else if (!strcmp(arg, "table"))
 		*format = FORMAT_TABLE;
 	else
@@ -170,7 +170,7 @@ static int parse_format_cb(const struct option *opt,
 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			 struct repository *repo)
 {
-	enum output_format format = FORMAT_KEYVALUE;
+	enum output_format format = FORMAT_NEWLINE_TERMINATED;
 	int all_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -185,7 +185,8 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
-	if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
+
+	if (format != FORMAT_NEWLINE_TERMINATED && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
 	if (all_keys && argc)
@@ -671,7 +672,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
 		stats_table_setup_structure(&table, &stats);
 		stats_table_print_structure(&table);
 		break;
-	case FORMAT_KEYVALUE:
+	case FORMAT_NEWLINE_TERMINATED:
 		structure_keyvalue_print(&stats, '=', '\n');
 		break;
 	case FORMAT_NUL_TERMINATED:
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 51d55f11a5..4155211e5d 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -34,7 +34,7 @@ test_repo_info () {
 		eval "$init_command $repo_name"
 	'
 
-	test_expect_success "keyvalue: $label" '
+	test_expect_success "lines: $label" '
 		echo "$key=$expected_value" > expect &&
 		git -C "$repo_name" repo info "$key" >actual &&
 		test_cmp expect actual
@@ -115,7 +115,7 @@ test_expect_success '-z uses nul-terminated format' '
 
 test_expect_success 'git repo info uses the last requested format' '
 	echo "layout.bare=false" >expected &&
-	git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
+	git repo info --format=nul -z --format=lines layout.bare >actual &&
 	test_cmp expected actual
 '
 
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 17ff164b05..a6f2591d9a 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -113,7 +113,7 @@ test_expect_success SHA1 'repository with references and objects' '
 	)
 '
 
-test_expect_success SHA1 'keyvalue and nul format' '
+test_expect_success SHA1 'lines and nul format' '
 	test_when_finished "rm -rf repo" &&
 	git init repo &&
 	(
@@ -140,7 +140,7 @@ test_expect_success SHA1 'keyvalue and nul format' '
 		objects.tags.disk_size=$(object_type_disk_usage tag)
 		EOF
 
-		git repo structure --format=keyvalue >out 2>err &&
+		git repo structure --format=lines >out 2>err &&
 
 		test_cmp expect out &&
 		test_line_count = 0 err &&
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v6 2/2] repo: add new flag --keys to git-repo-info
  2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  2026-02-14  0:35   ` [PATCH v6 1/2] repo: rename the output format " Lucas Seiki Oshiro
@ 2026-02-14  0:35   ` Lucas Seiki Oshiro
  2026-02-14 18:14   ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Junio C Hamano
  2 siblings, 0 replies; 40+ messages in thread
From: Lucas Seiki Oshiro @ 2026-02-14  0:35 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, jltobler, avila.jn, Lucas Seiki Oshiro

If the user wants to find what are the available keys, they need to
either check the documentation or to ask for all the key-value pairs
by using --all.

Add a new flag --keys for listing only the available keys without
listing the values.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
 Documentation/git-repo.adoc | 11 ++++++++++
 builtin/repo.c              | 32 +++++++++++++++++++++++++++++
 t/t1900-repo.sh             | 40 +++++++++++++++++++++++++++----------
 3 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 693e1bbced..319d30bd86 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,6 +9,7 @@ SYNOPSIS
 --------
 [synopsis]
 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]
 
 DESCRIPTION
@@ -45,6 +46,16 @@ supported:
 +
 `-z` is an alias for `--format=nul`.
 
+`info --keys [--format=(lines|nul) | -z]`::
+	List all the available keys, one per line. The output format can be chosen
+	through the flag `--format`. The following formats are supported:
++
+`lines`:::
+	Output the keys one per line. This is the default.
+
+`nul`:::
+	Similar to `lines`, but using a _NUL_ character after each value.
+
 `structure [--format=(table|lines|nul) | -z]`::
 	Retrieve statistics about the current repository structure. The
 	following kinds of information are reported:
diff --git a/builtin/repo.c b/builtin/repo.c
index 23c5ee88b0..6a62a6020a 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -18,6 +18,7 @@
 
 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
 };
@@ -148,6 +149,29 @@ static int print_all_fields(struct repository *repo,
 	return 0;
 }
 
+static int print_keys(enum output_format format)
+{
+	char sep;
+
+	switch (format) {
+	case FORMAT_NEWLINE_TERMINATED:
+		sep = '\n';
+		break;
+	case FORMAT_NUL_TERMINATED:
+		sep = '\0';
+		break;
+	default:
+		die(_("--keys can only be used with --format=lines or --format=nul"));
+	}
+
+	for (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
+		const struct field *field = &repo_info_fields[i];
+		printf("%s%c", field->key, sep);
+	}
+
+	return 0;
+}
+
 static int parse_format_cb(const struct option *opt,
 			   const char *arg, int unset UNUSED)
 {
@@ -172,6 +196,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 {
 	enum output_format format = FORMAT_NEWLINE_TERMINATED;
 	int all_keys = 0;
+	int show_keys = 0;
 	struct option options[] = {
 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
 			       N_("output format"),
@@ -181,11 +206,18 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
 			       parse_format_cb),
 		OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
+		OPT_BOOL(0, "keys", &show_keys, N_("show keys")),
 		OPT_END()
 	};
 
 	argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
 
+	if (show_keys && (all_keys || argc))
+		die(_("--keys cannot be used with a <key> or --all"));
+
+	if (show_keys)
+		return print_keys(format);
+
 	if (format != FORMAT_NEWLINE_TERMINATED && format != FORMAT_NUL_TERMINATED)
 		die(_("unsupported output format"));
 
diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 4155211e5d..a9eb07abe8 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -4,15 +4,6 @@ test_description='test git repo-info'
 
 . ./test-lib.sh
 
-# git-repo-info keys. It must contain the same keys listed in the const
-# repo_info_fields, in lexicographical order.
-REPO_INFO_KEYS='
-	layout.bare
-	layout.shallow
-	object.format
-	references.format
-'
-
 # Test whether a key-value pair is correctly returned
 #
 # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>
@@ -119,8 +110,8 @@ test_expect_success 'git repo info uses the last requested format' '
 	test_cmp expected actual
 '
 
-test_expect_success 'git repo info --all returns all key-value pairs' '
-	git repo info $REPO_INFO_KEYS >expect &&
+test_expect_success 'git repo info --all and git repo info $(git repo info --keys) output the same data' '
+	git repo info $(git repo info --keys) >expect &&
 	git repo info --all >actual &&
 	test_cmp expect actual
 '
@@ -131,4 +122,31 @@ test_expect_success 'git repo info --all <key> aborts' '
 	test_cmp expect actual
 '
 
+test_expect_success 'git repo info --keys --format=nul uses nul-terminated output' '
+	git repo info --keys --format=lines >lines &&
+	lf_to_nul <lines >expect &&
+	git repo info --keys --format=nul >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when using --format other than lines or nul' '
+	echo "fatal: --keys can only be used with --format=lines or --format=nul" >expect &&
+	test_must_fail git repo info --keys --format=table 2>actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'git repo info --keys aborts when requesting keys' '
+	echo "fatal: --keys cannot be used with a <key> or --all" >expect &&
+	test_must_fail git repo info --keys --all 2>actual_all &&
+	test_must_fail git repo info --keys some.key 2>actual_key &&
+	test_cmp expect actual_all &&
+	test_cmp expect actual_key
+'
+
+test_expect_success 'git repo info --keys uses lines as its default output format' '
+	git repo info --keys --format=lines >expect &&
+	git repo info --keys >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines"
  2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
  2026-02-14  0:35   ` [PATCH v6 1/2] repo: rename the output format " Lucas Seiki Oshiro
  2026-02-14  0:35   ` [PATCH v6 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
@ 2026-02-14 18:14   ` Junio C Hamano
  2026-02-16  6:59     ` Patrick Steinhardt
  2 siblings, 1 reply; 40+ messages in thread
From: Junio C Hamano @ 2026-02-14 18:14 UTC (permalink / raw)
  To: Lucas Seiki Oshiro; +Cc: git, ps, jltobler, avila.jn

Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:

> This v6 addresses these issues raised by Patrick:
>
> - It renames `FORMAT_LINES` to `FORMAT_NEWLINE_TERMINATED`
> - Change the commit messsage of the first patch (I'm using Patrick's
>   suggestion)
> - It capitalizes the new paragraphs
>
> There was a discussion about the name of the new format ("lines" vs
> "newline") [1]. Personally I prefer "lines" instead of "newline" because
> I understand the --format flag expects a format name (e.g. `table`,
> `lines`) instead of the delimiter, being `nul` only a short form of
> "nul-terminated". But, of course, I'm open to other opinions about it
> :-).

I'll refrain from commenting on this part, as I am not good at
naming ;-)

Changes relative to the previous round look all good.  Will replace.

Let's mark it for 'next'.

Thanks.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines"
  2026-02-14 18:14   ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Junio C Hamano
@ 2026-02-16  6:59     ` Patrick Steinhardt
  0 siblings, 0 replies; 40+ messages in thread
From: Patrick Steinhardt @ 2026-02-16  6:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Lucas Seiki Oshiro, git, jltobler, avila.jn

On Sat, Feb 14, 2026 at 10:14:24AM -0800, Junio C Hamano wrote:
> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
> 
> > This v6 addresses these issues raised by Patrick:
> >
> > - It renames `FORMAT_LINES` to `FORMAT_NEWLINE_TERMINATED`
> > - Change the commit messsage of the first patch (I'm using Patrick's
> >   suggestion)
> > - It capitalizes the new paragraphs
> >
> > There was a discussion about the name of the new format ("lines" vs
> > "newline") [1]. Personally I prefer "lines" instead of "newline" because
> > I understand the --format flag expects a format name (e.g. `table`,
> > `lines`) instead of the delimiter, being `nul` only a short form of
> > "nul-terminated". But, of course, I'm open to other opinions about it
> > :-).
> 
> I'll refrain from commenting on this part, as I am not good at
> naming ;-)
> 
> Changes relative to the previous round look all good.  Will replace.
> 
> Let's mark it for 'next'.

Agreed, this version looks good to me. Thanks!

Patrick

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2026-02-16  6:59 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-07 19:02 [PATCH] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2025-12-07 22:14 ` Junio C Hamano
2025-12-08 16:33   ` Lucas Seiki Oshiro
2025-12-08  7:13 ` Patrick Steinhardt
2025-12-09 19:36 ` [PATCH v2 0/2] " Lucas Seiki Oshiro
2025-12-09 19:36   ` [PATCH v2 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
2026-01-05 14:18     ` Patrick Steinhardt
2026-01-07 21:28       ` Lucas Seiki Oshiro
2026-01-08  6:13         ` Patrick Steinhardt
2025-12-09 19:36   ` [PATCH v2 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2026-01-05 14:18     ` Patrick Steinhardt
2026-01-05 13:57   ` [PATCH v2 0/2] " Lucas Seiki Oshiro
2026-01-05 14:19     ` Patrick Steinhardt
2026-01-09 20:31 ` [PATCH v3 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
2026-01-10  6:48   ` Junio C Hamano
2026-01-10  7:02     ` Junio C Hamano
2026-01-09 20:31 ` [PATCH v3 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
2026-01-09 20:31 ` [PATCH v3 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2026-01-10 12:04   ` Jean-Noël AVILA
2026-01-10 22:00     ` Lucas Seiki Oshiro
2026-01-12  8:40   ` Patrick Steinhardt
2026-01-19 20:20 ` [PATCH v4 0/2] repo: add --format=default and --keys Lucas Seiki Oshiro
2026-01-19 20:20   ` [PATCH v4 1/2] repo: add a default output format to enum output_format Lucas Seiki Oshiro
2026-01-19 20:20   ` [PATCH v4 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2026-01-20  6:05     ` Patrick Steinhardt
2026-01-20 23:11       ` Lucas Seiki Oshiro
2026-01-21  7:19         ` Patrick Steinhardt
2026-01-21 14:38           ` Lucas Seiki Oshiro
2026-01-20  0:52   ` [PATCH v4 0/2] repo: add --format=default and --keys Junio C Hamano
2026-01-23 16:34 ` [PATCH v5 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
2026-01-23 16:34   ` [PATCH v5 1/2] repo: " Lucas Seiki Oshiro
2026-01-27  6:58     ` Patrick Steinhardt
2026-01-23 16:34   ` [PATCH v5 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2026-01-27  6:58     ` Patrick Steinhardt
2026-01-27 22:27       ` Lucas Seiki Oshiro
2026-02-14  0:35 ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Lucas Seiki Oshiro
2026-02-14  0:35   ` [PATCH v6 1/2] repo: rename the output format " Lucas Seiki Oshiro
2026-02-14  0:35   ` [PATCH v6 2/2] repo: add new flag --keys to git-repo-info Lucas Seiki Oshiro
2026-02-14 18:14   ` [PATCH v6 0/2] repo: add --keys and rename "keyvalue" to "lines" Junio C Hamano
2026-02-16  6:59     ` Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox