* [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
@ 2025-11-30 19:59 Lucas Seiki Oshiro
2025-12-01 2:21 ` Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-11-30 19:59 UTC (permalink / raw)
To: git; +Cc: jltobler, Lucas Seiki Oshiro
Other Git commands that have nul-terminated output, such as git-config,
git-status, git-ls-files, and git-repo-info have a flag `-z` for using
the null character as the record separator.
Add the `-z` flag to git-repo-structure as an alias for `--format=nul`,
making it consistent with the behavior of the other commands.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
Hello, again!
Since git-repo-info and git-repo-structure share the same format parser, this
could be done by only copying the OPT_CALLBACK_F from repo_info.
I'm cc'ing Justin here, as he was the author of git-repo-structure.
This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)
with lo/repo-info-all merged.
Documentation/git-repo.adoc | 5 +++--
builtin/repo.c | 6 +++++-
t/t1901-repo-structure.sh | 6 ++++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 70f0a6d2e4..8820954f7e 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[synopsis]
git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul)]
+git repo structure [--format=(table|keyvalue|nul)] [-z]
DESCRIPTION
-----------
@@ -44,7 +44,7 @@ supported:
+
`-z` is an alias for `--format=nul`.
-`structure [--format=(table|keyvalue|nul)]`::
+`structure [--format=(table|keyvalue|nul)] [-z]`::
Retrieve statistics about the current repository structure. The
following kinds of information are reported:
+
@@ -72,6 +72,7 @@ supported:
the delimiter between the key and value instead of '='. Unlike the
`keyvalue` format, values containing "unusual" characters are never
quoted.
+`-z` is an alias for `--format=nul`.
INFO KEYS
---------
diff --git a/builtin/repo.c b/builtin/repo.c
index 2a653bd3ea..1c06207a39 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -16,7 +16,7 @@
static const char *const repo_usage[] = {
"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
- "git repo structure [--format=(table|keyvalue|nul)]",
+ "git repo structure [--format=(table|keyvalue|nul)] [-z]",
NULL
};
@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
OPT_CALLBACK_F(0, "format", &format, N_("format"),
N_("output format"),
PARSE_OPT_NONEG, parse_format_cb),
+ OPT_CALLBACK_F('z', NULL, &format, NULL,
+ N_("synonym for --format=nul"),
+ PARSE_OPT_NONEG | PARSE_OPT_NOARG,
+ parse_format_cb),
OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
OPT_END()
};
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 36a71a144e..5a50acf345 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
tr "\n=" "\0\n" <expect >expect_nul &&
git repo structure --format=nul >out 2>err &&
+ test_cmp expect_nul out &&
+ test_line_count = 0 err &&
+
+ # Check -z
+ git repo structure --format=nul >out 2>err &&
+
test_cmp expect_nul out &&
test_line_count = 0 err
)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-11-30 19:59 [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
@ 2025-12-01 2:21 ` Junio C Hamano
2025-12-01 8:28 ` Patrick Steinhardt
2025-12-01 15:11 ` Justin Tobler
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2025-12-01 2:21 UTC (permalink / raw)
To: Lucas Seiki Oshiro; +Cc: git, jltobler
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
> -git repo structure [--format=(table|keyvalue|nul)]
> +git repo structure [--format=(table|keyvalue|nul)] [-z]
It's a minor thing but I wonder if this should be more like
git repo structure [--format=(table|keyvalue|nul) | -z]
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> index 36a71a144e..5a50acf345 100755
> --- a/t/t1901-repo-structure.sh
> +++ b/t/t1901-repo-structure.sh
> @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
> tr "\n=" "\0\n" <expect >expect_nul &&
> git repo structure --format=nul >out 2>err &&
>
> + test_cmp expect_nul out &&
> + test_line_count = 0 err &&
> +
> + # Check -z
> + git repo structure --format=nul >out 2>err &&
Didn't you want to check "-z", not "--format=nul"? In addition,
perhaps test
# "-z", as a synonym to "--format=nul", participates in the
# usual "last one wins" rule.
git repo structure --format=table -z >out 2>err &&
as well, or is it too obvious (by knowing how parse-options API is
used) that it is pointless to test?
> test_cmp expect_nul out &&
> test_line_count = 0 err
> )
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-01 2:21 ` Junio C Hamano
@ 2025-12-01 8:28 ` Patrick Steinhardt
2025-12-01 14:34 ` Lucas Seiki Oshiro
2025-12-02 3:45 ` Junio C Hamano
0 siblings, 2 replies; 15+ messages in thread
From: Patrick Steinhardt @ 2025-12-01 8:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Lucas Seiki Oshiro, git, jltobler
On Sun, Nov 30, 2025 at 06:21:21PM -0800, Junio C Hamano wrote:
> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
>
> > -git repo structure [--format=(table|keyvalue|nul)]
> > +git repo structure [--format=(table|keyvalue|nul)] [-z]
>
> It's a minor thing but I wonder if this should be more like
>
> git repo structure [--format=(table|keyvalue|nul) | -z]
This discussion rings a bell -- didn't we already discuss this for `git
repo info`? Yup, indeed [1]. Initial versions of `git repo info `-z`
also had it formatted like the above, but the discussion eventually led
to a version that is the same as the one proposed in this patch here.
I think this ultimately stems from [2], where you argue that it _is_
possible to say `git repo info --format=table -z`, and the last option
wins. It's the same for `git repo structure`, so I'd argue we should be
consistent.
[1]: <20250820144247.79197-1-lucasseikioshiro@gmail.com>
[2]: <xmqqcy8frqn2.fsf@gitster.g>
> > diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> > index 36a71a144e..5a50acf345 100755
> > --- a/t/t1901-repo-structure.sh
> > +++ b/t/t1901-repo-structure.sh
> > @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
> > tr "\n=" "\0\n" <expect >expect_nul &&
> > git repo structure --format=nul >out 2>err &&
> >
> > + test_cmp expect_nul out &&
> > + test_line_count = 0 err &&
> > +
> > + # Check -z
> > + git repo structure --format=nul >out 2>err &&
>
> Didn't you want to check "-z", not "--format=nul"? In addition,
> perhaps test
>
> # "-z", as a synonym to "--format=nul", participates in the
> # usual "last one wins" rule.
> git repo structure --format=table -z >out 2>err &&
>
> as well, or is it too obvious (by knowing how parse-options API is
> used) that it is pointless to test?
I think it wouldn't be pointless given the above -- we should verify
that the last one wins, regardless of whether you use the alias or the
long option.
Patrick
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-01 8:28 ` Patrick Steinhardt
@ 2025-12-01 14:34 ` Lucas Seiki Oshiro
2025-12-02 3:45 ` Junio C Hamano
1 sibling, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-01 14:34 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: Junio C Hamano, git, jltobler
> I think this ultimately stems from [2], where you argue that it _is_
> possible to say `git repo info --format=table -z`, and the last option
> wins. It's the same for `git repo structure`, so I'd argue we should be
> consistent.
Yeah, I agree. I'm also ok with `[--format ... | -z]`, but given that
this argument parsing git-repo-stucture is the same from git-repo-info,
it wouldn't make sense that their synopses differ.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-11-30 19:59 [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-01 2:21 ` Junio C Hamano
@ 2025-12-01 15:11 ` Justin Tobler
2025-12-02 0:29 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2 siblings, 1 reply; 15+ messages in thread
From: Justin Tobler @ 2025-12-01 15:11 UTC (permalink / raw)
To: Lucas Seiki Oshiro; +Cc: git
On 25/11/30 04:59PM, Lucas Seiki Oshiro wrote:
> Other Git commands that have nul-terminated output, such as git-config,
> git-status, git-ls-files, and git-repo-info have a flag `-z` for using
> the null character as the record separator.
>
> Add the `-z` flag to git-repo-structure as an alias for `--format=nul`,
> making it consistent with the behavior of the other commands.
>
> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
> ---
>
> Hello, again!
>
> Since git-repo-info and git-repo-structure share the same format parser, this
> could be done by only copying the OPT_CALLBACK_F from repo_info.
>
> I'm cc'ing Justin here, as he was the author of git-repo-structure.
Thanks Lucas, looks like you beat me to this change. :)
> This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)
> with lo/repo-info-all merged.
Any reason this isn't just based on master? It looks like this patch
should apply just fine as I don't see any dependencies.
> Documentation/git-repo.adoc | 5 +++--
> builtin/repo.c | 6 +++++-
> t/t1901-repo-structure.sh | 6 ++++++
> 3 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
> index 70f0a6d2e4..8820954f7e 100644
> --- a/Documentation/git-repo.adoc
> +++ b/Documentation/git-repo.adoc
> @@ -9,7 +9,7 @@ SYNOPSIS
> --------
> [synopsis]
> git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
> -git repo structure [--format=(table|keyvalue|nul)]
> +git repo structure [--format=(table|keyvalue|nul)] [-z]
>
> DESCRIPTION
> -----------
> @@ -44,7 +44,7 @@ supported:
> +
> `-z` is an alias for `--format=nul`.
>
> -`structure [--format=(table|keyvalue|nul)]`::
> +`structure [--format=(table|keyvalue|nul)] [-z]`::
> Retrieve statistics about the current repository structure. The
> following kinds of information are reported:
> +
> @@ -72,6 +72,7 @@ supported:
> the delimiter between the key and value instead of '='. Unlike the
> `keyvalue` format, values containing "unusual" characters are never
> quoted.
> +`-z` is an alias for `--format=nul`.
If we want to match the format in the section prior, we should add a '+'
character on the prior line to separate the sections. With how it is
written now, this line will just be appeneded to the previous section.
> INFO KEYS
> ---------
> diff --git a/builtin/repo.c b/builtin/repo.c
> index 2a653bd3ea..1c06207a39 100644
> --- a/builtin/repo.c
> +++ b/builtin/repo.c
> @@ -16,7 +16,7 @@
>
> static const char *const repo_usage[] = {
> "git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
> - "git repo structure [--format=(table|keyvalue|nul)]",
> + "git repo structure [--format=(table|keyvalue|nul)] [-z]",
> NULL
> };
>
> @@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
> OPT_CALLBACK_F(0, "format", &format, N_("format"),
> N_("output format"),
> PARSE_OPT_NONEG, parse_format_cb),
> + OPT_CALLBACK_F('z', NULL, &format, NULL,
> + N_("synonym for --format=nul"),
> + PARSE_OPT_NONEG | PARSE_OPT_NOARG,
> + parse_format_cb),
Reusing the same `parse_format_cb()` makes sense and also matches what
we do with git-repo-info. Looks good.
> OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
> OPT_END()
> };
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> index 36a71a144e..5a50acf345 100755
> --- a/t/t1901-repo-structure.sh
> +++ b/t/t1901-repo-structure.sh
> @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
> tr "\n=" "\0\n" <expect >expect_nul &&
> git repo structure --format=nul >out 2>err &&
>
> + test_cmp expect_nul out &&
> + test_line_count = 0 err &&
> +
> + # Check -z
> + git repo structure --format=nul >out 2>err &&
Did you mean to use the -z option here?
-Justin
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-01 15:11 ` Justin Tobler
@ 2025-12-02 0:29 ` Lucas Seiki Oshiro
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-02 0:29 UTC (permalink / raw)
To: Justin Tobler; +Cc: git, Junio C Hamano, Patrick Steinhardt
Hi!
>> This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)
>> with lo/repo-info-all merged.
>
> Any reason this isn't just based on master? It looks like this patch
> should apply just fine as I don't see any dependencies.
Yesterday, lo/repo-info-all wasn't merged yet to master :-)
> Reusing the same `parse_format_cb()` makes sense and also matches what
> we do with git-repo-info. Looks good.
Yes, this callback is used by both subcommands, this was a really
straightforward change.
> Did you mean to use the -z option here?
Ooops, yes, sorry. I'll fix it.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-01 8:28 ` Patrick Steinhardt
2025-12-01 14:34 ` Lucas Seiki Oshiro
@ 2025-12-02 3:45 ` Junio C Hamano
2025-12-02 22:05 ` Lucas Seiki Oshiro
1 sibling, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2025-12-02 3:45 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: Lucas Seiki Oshiro, git, jltobler
Patrick Steinhardt <ps@pks.im> writes:
> I think this ultimately stems from [2], where you argue that it _is_
> possible to say `git repo info --format=table -z`, and the last option
> wins. It's the same for `git repo structure`, so I'd argue we should be
> consistent.
I do not think so; [2] was about the explicit "--format=nul and -z
are incompatible" code. Even without this '-z" thing, if you have
[--opt=(a|b|c)]
I _think_ our intention is to allow "git cmd --opt=a --opt=b" from
the user and let the last one win. If you add "-z",
[--format=(table|keyvalue|nul)] [-z]
[--format=(table|keyvalue|nul) | -z]
I think both would mean the same thing; I just was wonering if
grouping them together in one bracket makes it more obvious that
these are all options to control the output format.
There was also an inquiry about writing it like
[(--format=(table|keyvalue|nul) | -z)]
or even
[(--format=(table|keyvalue|nul) | -z)...]
as these can be repeated and let the last-one-wins rule decide the
final outcome, but we do not do that. I thought the final comment
on this was in
https://lore.kernel.org/git/6186055.lOV4Wx5bFT@cayenne/
where the message said
In fact the correct formatting is:
[--format=(keyvalue|nul) | -z] [<key>...]
As stated in "CodingGuidelines:
Use spacing around "|" token(s), but not immediately after opening or
before closing a [] or () pair:
Do: [-q | --quiet]
Don't: [-q|--quiet]
Don't use spacing around "|" tokens when they're used to separate the
alternate arguments of an option:
Do: --track[=(direct|inherit)]
Don't: --track[=(direct | inherit)]
and that was where the thread ended, I think.
> [1]: <20250820144247.79197-1-lucasseikioshiro@gmail.com>
> [2]: <xmqqcy8frqn2.fsf@gitster.g>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-02 3:45 ` Junio C Hamano
@ 2025-12-02 22:05 ` Lucas Seiki Oshiro
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-02 22:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Patrick Steinhardt, git, jltobler
> I thought the final comment on this was in
>
> https://lore.kernel.org/git/6186055.lOV4Wx5bFT@cayenne/
Actually, the final comment was [1], after the version where I use
`[--format=...] [-z]`.
But actually, I don't have a strong opinion on using `| -z` vs using
`[-z]`, since both work here, but if `| -z` looks clearer, I can
change it in the next version. However, I'll do that for both
repo-info and repo-structure, since --format is parsed by the same
function in both of them.
[1]: <xmqqms7cltak.fsf@gitster.g <mailto:xmqqms7cltak.fsf@gitster.g>>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 0/3] repo: add -z as an alias for --format=nul to git-repo-structure
2025-11-30 19:59 [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-01 2:21 ` Junio C Hamano
2025-12-01 15:11 ` Justin Tobler
@ 2025-12-04 20:10 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc Lucas Seiki Oshiro
` (3 more replies)
2 siblings, 4 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-04 20:10 UTC (permalink / raw)
To: git; +Cc: gitster, jltobler, ps, Lucas Seiki Oshiro
Hi!
The main objective of this patchset is to add -z to git-repo-structure as
an alias for --format=nul. I'm including two other related patches here:
- a patch removing an extra line in the documentation, which was leaking an + to
the generated files
- a patch replacing `[--format=...] [-z]` by `[--format=... | -z]` in
git-repo-info's synopsis
Lucas Seiki Oshiro (3):
repo: remove blank line from Documentation/git-repo.adoc
repo: use [--format=... | -z] instead of [-z] in git-repo-info
synopsis
repo: add -z as an alias for --format=nul to git-repo-structure
Documentation/git-repo.adoc | 11 ++++++-----
builtin/repo.c | 8 ++++++--
t/t1901-repo-structure.sh | 7 +++++++
3 files changed, 19 insertions(+), 7 deletions(-)
Range-diff against v1:
-: ---------- > 1: bfd4ff5db0 repo: remove blank line from Documentation/git-repo.adoc
-: ---------- > 2: e5eac8713c repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis
1: f051cd41de ! 3: 0ccec7037d repo: add -z as an alias for --format=nul to git-repo-structure
@@ Documentation/git-repo.adoc
@@ Documentation/git-repo.adoc: SYNOPSIS
--------
[synopsis]
- git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
+ git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul)]
-+git repo structure [--format=(table|keyvalue|nul)] [-z]
++git repo structure [--format=(table|keyvalue|nul) | -z]
DESCRIPTION
-----------
@@ Documentation/git-repo.adoc: supported:
`-z` is an alias for `--format=nul`.
-`structure [--format=(table|keyvalue|nul)]`::
-+`structure [--format=(table|keyvalue|nul)] [-z]`::
++`structure [--format=(table|keyvalue|nul) | -z]`::
Retrieve statistics about the current repository structure. The
following kinds of information are reported:
+
@@ Documentation/git-repo.adoc: supported:
the delimiter between the key and value instead of '='. Unlike the
`keyvalue` format, values containing "unusual" characters are never
quoted.
+++
+`-z` is an alias for `--format=nul`.
INFO KEYS
@@ builtin/repo.c
@@
static const char *const repo_usage[] = {
- "git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
+ "git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
- "git repo structure [--format=(table|keyvalue|nul)]",
-+ "git repo structure [--format=(table|keyvalue|nul)] [-z]",
++ "git repo structure [--format=(table|keyvalue|nul) | -z]",
NULL
};
@@ t/t1901-repo-structure.sh: test_expect_success 'keyvalue and nul format' '
+ test_cmp expect_nul out &&
+ test_line_count = 0 err &&
+
-+ # Check -z
-+ git repo structure --format=nul >out 2>err &&
++ # "-z", as a synonym to "--format=nul", participates in the
++ # usual "last one wins" rule.
++ git repo structure --format=table -z >out 2>err &&
+
test_cmp expect_nul out &&
test_line_count = 0 err
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
@ 2025-12-04 20:10 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis Lucas Seiki Oshiro
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-04 20:10 UTC (permalink / raw)
To: git; +Cc: gitster, jltobler, ps, Lucas Seiki Oshiro
There was an extra blank line in git-repo-structure documentation, which
led to an unwawnted '+' character after generating an HTML or PDF from
that page. This can be seen, for example, in Git 2.52.0 online docs [1].
Remove that extra line.
[1] https://git-scm.com/docs/git-repo/2.52.0
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
Documentation/git-repo.adoc | 1 -
1 file changed, 1 deletion(-)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 70f0a6d2e4..5d9c7641c2 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -50,7 +50,6 @@ supported:
+
* Reference counts categorized by type
* Reachable object counts categorized by type
-
+
The output format can be chosen through the flag `--format`. Three formats are
supported:
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc Lucas Seiki Oshiro
@ 2025-12-04 20:10 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-05 11:09 ` [PATCH v2 0/3] " Patrick Steinhardt
3 siblings, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-04 20:10 UTC (permalink / raw)
To: git; +Cc: gitster, jltobler, ps, Lucas Seiki Oshiro
The flag -z is only an alias for --format=null and even though --format
and -z can be used together and repeated, only the last one is
considered.
Replace `[-z]` in the synopsis of git-repo-info by
`[--format=... | -z]`, expliciting that the use of one of those flags
replace the other.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
Documentation/git-repo.adoc | 4 ++--
builtin/repo.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 5d9c7641c2..f24514deaa 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -8,7 +8,7 @@ git-repo - Retrieve information about the repository
SYNOPSIS
--------
[synopsis]
-git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
+git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
git repo structure [--format=(table|keyvalue|nul)]
DESCRIPTION
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
COMMANDS
--------
-`info [--format=(keyvalue|nul)] [-z] [--all | <key>...]`::
+`info [--format=(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).
diff --git a/builtin/repo.c b/builtin/repo.c
index 2a653bd3ea..cc97dd1836 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -15,7 +15,7 @@
#include "utf8.h"
static const char *const repo_usage[] = {
- "git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
+ "git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
"git repo structure [--format=(table|keyvalue|nul)]",
NULL
};
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis Lucas Seiki Oshiro
@ 2025-12-04 20:10 ` Lucas Seiki Oshiro
2025-12-11 5:23 ` Junio C Hamano
2025-12-05 11:09 ` [PATCH v2 0/3] " Patrick Steinhardt
3 siblings, 1 reply; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-04 20:10 UTC (permalink / raw)
To: git; +Cc: gitster, jltobler, ps, Lucas Seiki Oshiro
Other Git commands that have nul-terminated output, such as git-config,
git-status, git-ls-files, and git-repo-info have a flag `-z` for using
the null character as the record separator.
Add the `-z` flag to git-repo-structure as an alias for `--format=nul`,
making it consistent with the behavior of the other commands.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
Documentation/git-repo.adoc | 6 ++++--
builtin/repo.c | 6 +++++-
t/t1901-repo-structure.sh | 7 +++++++
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index f24514deaa..c4a78277df 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[synopsis]
git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul)]
+git repo structure [--format=(table|keyvalue|nul) | -z]
DESCRIPTION
-----------
@@ -44,7 +44,7 @@ supported:
+
`-z` is an alias for `--format=nul`.
-`structure [--format=(table|keyvalue|nul)]`::
+`structure [--format=(table|keyvalue|nul) | -z]`::
Retrieve statistics about the current repository structure. The
following kinds of information are reported:
+
@@ -71,6 +71,8 @@ supported:
the delimiter between the key and value instead of '='. Unlike the
`keyvalue` format, values containing "unusual" characters are never
quoted.
++
+`-z` is an alias for `--format=nul`.
INFO KEYS
---------
diff --git a/builtin/repo.c b/builtin/repo.c
index cc97dd1836..0dd41b1778 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -16,7 +16,7 @@
static const char *const repo_usage[] = {
"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
- "git repo structure [--format=(table|keyvalue|nul)]",
+ "git repo structure [--format=(table|keyvalue|nul) | -z]",
NULL
};
@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
OPT_CALLBACK_F(0, "format", &format, N_("format"),
N_("output format"),
PARSE_OPT_NONEG, parse_format_cb),
+ OPT_CALLBACK_F('z', NULL, &format, NULL,
+ N_("synonym for --format=nul"),
+ PARSE_OPT_NONEG | PARSE_OPT_NOARG,
+ parse_format_cb),
OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
OPT_END()
};
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 36a71a144e..df7d4ea524 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' '
tr "\n=" "\0\n" <expect >expect_nul &&
git repo structure --format=nul >out 2>err &&
+ test_cmp expect_nul out &&
+ test_line_count = 0 err &&
+
+ # "-z", as a synonym to "--format=nul", participates in the
+ # usual "last one wins" rule.
+ git repo structure --format=table -z >out 2>err &&
+
test_cmp expect_nul out &&
test_line_count = 0 err
)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/3] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
` (2 preceding siblings ...)
2025-12-04 20:10 ` [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
@ 2025-12-05 11:09 ` Patrick Steinhardt
3 siblings, 0 replies; 15+ messages in thread
From: Patrick Steinhardt @ 2025-12-05 11:09 UTC (permalink / raw)
To: Lucas Seiki Oshiro; +Cc: git, gitster, jltobler
On Thu, Dec 04, 2025 at 05:10:09PM -0300, Lucas Seiki Oshiro wrote:
> Hi!
>
> The main objective of this patchset is to add -z to git-repo-structure as
> an alias for --format=nul. I'm including two other related patches here:
>
> - a patch removing an extra line in the documentation, which was leaking an + to
> the generated files
>
> - a patch replacing `[--format=...] [-z]` by `[--format=... | -z]` in
> git-repo-info's synopsis
This version looks good to me, thanks!
Patrick
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-04 20:10 ` [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
@ 2025-12-11 5:23 ` Junio C Hamano
2025-12-18 23:02 ` Lucas Seiki Oshiro
0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2025-12-11 5:23 UTC (permalink / raw)
To: Lucas Seiki Oshiro; +Cc: git, jltobler, ps
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> index 36a71a144e..df7d4ea524 100755
> --- a/t/t1901-repo-structure.sh
> +++ b/t/t1901-repo-structure.sh
> @@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' '
> tr "\n=" "\0\n" <expect >expect_nul &&
> git repo structure --format=nul >out 2>err &&
> + test_cmp expect_nul out &&
> + test_line_count = 0 err &&
Not limited to this step, but I have a couple of comments.
* Instead of munging the expected file so that it contains a NUL,
and compare the actual output with it, munge the NUL terminated
outout to make it text and compare with the expected file in text
format. This matters when tests start to fail as test_cmp will
show the "diff" output when it fails, and comparing NUL
terminated files, which are "binary" in the eyes of the "diff"
utility.
* I see your -z output is "<key> LF <value> NUL", but was there a
particular reason why "<key> NUL <value> NUL" was not chosen?
Unless there is a compelling reason not to, it would be a lot
more future-proof to use NUL for both, primarily because it would
allow future developers to include arbitrary non-NUL bytes in the
<key> part in the future (and we wouldn't know what end-user
controlled substring they may want to add).
> +
> + # "-z", as a synonym to "--format=nul", participates in the
> + # usual "last one wins" rule.
> + git repo structure --format=table -z >out 2>err &&
> +
> test_cmp expect_nul out &&
> test_line_count = 0 err
> )
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure
2025-12-11 5:23 ` Junio C Hamano
@ 2025-12-18 23:02 ` Lucas Seiki Oshiro
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Seiki Oshiro @ 2025-12-18 23:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, jltobler, ps
Hi, Junio!
> * Instead of munging the expected file so that it contains a NUL,
> and compare the actual output with it, munge the NUL terminated
> outout to make it text and compare with the expected file in text
> format.
Ok! I'll do that in the next version.
> * I see your -z output is "<key> LF <value> NUL", but was there a
> particular reason why "<key> NUL <value> NUL" was not chosen?
This was a suggestions by Phillip Wood [1]. We've chosen this format
following the format of git-config.
[1] https://lore.kernel.org/git/223c7cbd-610e-49e2-90e2-5914cbc0f1d7@gmail.com/
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2025-12-18 23:02 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-30 19:59 [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-01 2:21 ` Junio C Hamano
2025-12-01 8:28 ` Patrick Steinhardt
2025-12-01 14:34 ` Lucas Seiki Oshiro
2025-12-02 3:45 ` Junio C Hamano
2025-12-02 22:05 ` Lucas Seiki Oshiro
2025-12-01 15:11 ` Justin Tobler
2025-12-02 0:29 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-11 5:23 ` Junio C Hamano
2025-12-18 23:02 ` Lucas Seiki Oshiro
2025-12-05 11:09 ` [PATCH v2 0/3] " Patrick Steinhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).