{"thread":{"id":"64559","subject":"[PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","startedAt":"2025-11-30T20:35:26Z","lastAt":"2025-12-18T23:02:50Z","messageCount":15,"participants":["Lucas Seiki Oshiro","Junio C Hamano","Patrick Steinhardt","Justin Tobler"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"531480","messageId":"20251130203456.28437-1-lucasseikioshiro@gmail.com","threadId":"64559","inReplyTo":null,"subject":"[PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-30T19:59:55Z","receivedAt":"2025-11-30T20:35:26Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Other Git commands that have nul-terminated output, such as git-config,\ngit-status, git-ls-files, and git-repo-info have a flag `-z` for using\nthe null character as the record separator.\n\nAdd the `-z` flag to git-repo-structure as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n\nHello, again!\n\nSince git-repo-info and git-repo-structure share the same format parser, this\ncould be done by only copying the OPT_CALLBACK_F from repo_info.\n\nI'm cc'ing Justin here, as he was the author of git-repo-structure.\n\nThis patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)\nwith lo/repo-info-all merged.\n\n Documentation/git-repo.adoc | 5 +++--\n builtin/repo.c              | 6 +++++-\n t/t1901-repo-structure.sh   | 6 ++++++\n 3 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 70f0a6d2e4..8820954f7e 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [synopsis]\n git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n-git repo structure [--format=(table|keyvalue|nul)]\n+git repo structure [--format=(table|keyvalue|nul)] [-z]\n \n DESCRIPTION\n -----------\n@@ -44,7 +44,7 @@ supported:\n +\n `-z` is an alias for `--format=nul`.\n \n-`structure [--format=(table|keyvalue|nul)]`::\n+`structure [--format=(table|keyvalue|nul)] [-z]`::\n \tRetrieve statistics about the current repository structure. The\n \tfollowing kinds of information are reported:\n +\n@@ -72,6 +72,7 @@ supported:\n \tthe delimiter between the key and value instead of '='. Unlike the\n \t`keyvalue` format, values containing \"unusual\" characters are never\n \tquoted.\n+`-z` is an alias for `--format=nul`.\n \n INFO KEYS\n ---------\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 2a653bd3ea..1c06207a39 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -16,7 +16,7 @@\n \n static const char *const repo_usage[] = {\n \t\"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\",\n-\t\"git repo structure [--format=(table|keyvalue|nul)]\",\n+\t\"git repo structure [--format=(table|keyvalue|nul)] [-z]\",\n \tNULL\n };\n \n@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n \t\t\t       PARSE_OPT_NONEG, parse_format_cb),\n+\t\tOPT_CALLBACK_F('z', NULL, &format, NULL,\n+\t\t\t       N_(\"synonym for --format=nul\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       parse_format_cb),\n \t\tOPT_BOOL(0, \"progress\", &show_progress, N_(\"show progress\")),\n \t\tOPT_END()\n \t};\ndiff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\nindex 36a71a144e..5a50acf345 100755\n--- a/t/t1901-repo-structure.sh\n+++ b/t/t1901-repo-structure.sh\n@@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '\n \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n \t\tgit repo structure --format=nul >out 2>err &&\n \n+\t\ttest_cmp expect_nul out &&\n+\t\ttest_line_count = 0 err &&\n+\n+\t\t# Check -z\n+\t\tgit repo structure --format=nul >out 2>err &&\n+\n \t\ttest_cmp expect_nul out &&\n \t\ttest_line_count = 0 err\n \t)\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"531481","messageId":"xmqqms43aqn2.fsf@gitster.g","threadId":"64559","inReplyTo":"20251130203456.28437-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-01T02:21:21Z","receivedAt":"2025-12-01T02:21:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n\n> -git repo structure [--format=(table|keyvalue|nul)]\n> +git repo structure [--format=(table|keyvalue|nul)] [-z]\n\n\nIt's a minor thing but I wonder if this should be more like\n\n    git repo structure [--format=(table|keyvalue|nul) | -z]\n\n> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\n> index 36a71a144e..5a50acf345 100755\n> --- a/t/t1901-repo-structure.sh\n> +++ b/t/t1901-repo-structure.sh\n> @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '\n>  \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n>  \t\tgit repo structure --format=nul >out 2>err &&\n>  \n> +\t\ttest_cmp expect_nul out &&\n> +\t\ttest_line_count = 0 err &&\n> +\n> +\t\t# Check -z\n> +\t\tgit repo structure --format=nul >out 2>err &&\n\nDidn't you want to check \"-z\", not \"--format=nul\"?  In addition,\nperhaps test\n\n\t# \"-z\", as a synonym to \"--format=nul\", participates in the\n\t# usual \"last one wins\" rule.\n\tgit repo structure --format=table -z >out 2>err &&\n\nas well, or is it too obvious (by knowing how parse-options API is\nused) that it is pointless to test?\n\n>  \t\ttest_cmp expect_nul out &&\n>  \t\ttest_line_count = 0 err\n>  \t)\n"},{"id":"531487","messageId":"aS1Rvy9J2KjWrQb4@pks.im","threadId":"64559","inReplyTo":"xmqqms43aqn2.fsf@gitster.g","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-12-01T08:28:47Z","receivedAt":"2025-12-01T08:28:53Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Nov 30, 2025 at 06:21:21PM -0800, Junio C Hamano wrote:\n> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n> \n> > -git repo structure [--format=(table|keyvalue|nul)]\n> > +git repo structure [--format=(table|keyvalue|nul)] [-z]\n> \n> It's a minor thing but I wonder if this should be more like\n> \n>     git repo structure [--format=(table|keyvalue|nul) | -z]\n\nThis discussion rings a bell -- didn't we already discuss this for `git\nrepo info`? Yup, indeed [1]. Initial versions of `git repo info `-z`\nalso had it formatted like the above, but the discussion eventually led\nto a version that is the same as the one proposed in this patch here.\n\nI think this ultimately stems from [2], where you argue that it _is_\npossible to say `git repo info --format=table -z`, and the last option\nwins. It's the same for `git repo structure`, so I'd argue we should be\nconsistent.\n\n[1]: <20250820144247.79197-1-lucasseikioshiro@gmail.com>\n[2]: <xmqqcy8frqn2.fsf@gitster.g>\n\n> > diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\n> > index 36a71a144e..5a50acf345 100755\n> > --- a/t/t1901-repo-structure.sh\n> > +++ b/t/t1901-repo-structure.sh\n> > @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '\n> >  \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n> >  \t\tgit repo structure --format=nul >out 2>err &&\n> >  \n> > +\t\ttest_cmp expect_nul out &&\n> > +\t\ttest_line_count = 0 err &&\n> > +\n> > +\t\t# Check -z\n> > +\t\tgit repo structure --format=nul >out 2>err &&\n> \n> Didn't you want to check \"-z\", not \"--format=nul\"?  In addition,\n> perhaps test\n> \n> \t# \"-z\", as a synonym to \"--format=nul\", participates in the\n> \t# usual \"last one wins\" rule.\n> \tgit repo structure --format=table -z >out 2>err &&\n> \n> as well, or is it too obvious (by knowing how parse-options API is\n> used) that it is pointless to test?\n\nI think it wouldn't be pointless given the above -- we should verify\nthat the last one wins, regardless of whether you use the alias or the\nlong option.\n\nPatrick\n"},{"id":"531519","messageId":"EBC0724E-A53C-4219-B314-1C8382584297@gmail.com","threadId":"64559","inReplyTo":"aS1Rvy9J2KjWrQb4@pks.im","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-01T14:34:39Z","receivedAt":"2025-12-01T14:34:53Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> I think this ultimately stems from [2], where you argue that it _is_\n> possible to say `git repo info --format=table -z`, and the last option\n> wins. It's the same for `git repo structure`, so I'd argue we should be\n> consistent.\n\nYeah, I agree. I'm also ok with `[--format ... | -z]`, but given that\nthis argument parsing git-repo-stucture is the same from git-repo-info,\nit wouldn't make sense that their synopses differ.\n"},{"id":"531520","messageId":"3hzpywampwjfsckljdqhyabhkupqmrzbcsc7fhrkg2cl4rjzzm@mygtkda7soxj","threadId":"64559","inReplyTo":"20251130203456.28437-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-12-01T15:11:24Z","receivedAt":"2025-12-01T15:11:29Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/11/30 04:59PM, Lucas Seiki Oshiro wrote:\n> Other Git commands that have nul-terminated output, such as git-config,\n> git-status, git-ls-files, and git-repo-info have a flag `-z` for using\n> the null character as the record separator.\n> \n> Add the `-z` flag to git-repo-structure as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n> \n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n> \n> Hello, again!\n> \n> Since git-repo-info and git-repo-structure share the same format parser, this\n> could be done by only copying the OPT_CALLBACK_F from repo_info.\n> \n> I'm cc'ing Justin here, as he was the author of git-repo-structure.\n\nThanks Lucas, looks like you beat me to this change. :)\n\n> This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)\n> with lo/repo-info-all merged.\n\nAny reason this isn't just based on master? It looks like this patch\nshould apply just fine as I don't see any dependencies.\n\n>  Documentation/git-repo.adoc | 5 +++--\n>  builtin/repo.c              | 6 +++++-\n>  t/t1901-repo-structure.sh   | 6 ++++++\n>  3 files changed, 14 insertions(+), 3 deletions(-)\n> \n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index 70f0a6d2e4..8820954f7e 100644\n> --- a/Documentation/git-repo.adoc\n> +++ b/Documentation/git-repo.adoc\n> @@ -9,7 +9,7 @@ SYNOPSIS\n>  --------\n>  [synopsis]\n>  git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n> -git repo structure [--format=(table|keyvalue|nul)]\n> +git repo structure [--format=(table|keyvalue|nul)] [-z]\n>  \n>  DESCRIPTION\n>  -----------\n> @@ -44,7 +44,7 @@ supported:\n>  +\n>  `-z` is an alias for `--format=nul`.\n>  \n> -`structure [--format=(table|keyvalue|nul)]`::\n> +`structure [--format=(table|keyvalue|nul)] [-z]`::\n>  \tRetrieve statistics about the current repository structure. The\n>  \tfollowing kinds of information are reported:\n>  +\n> @@ -72,6 +72,7 @@ supported:\n>  \tthe delimiter between the key and value instead of '='. Unlike the\n>  \t`keyvalue` format, values containing \"unusual\" characters are never\n>  \tquoted.\n> +`-z` is an alias for `--format=nul`.\n\nIf we want to match the format in the section prior, we should add a '+'\ncharacter on the prior line to separate the sections. With how it is\nwritten now, this line will just be appeneded to the previous section.\n\n>  INFO KEYS\n>  ---------\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 2a653bd3ea..1c06207a39 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -16,7 +16,7 @@\n>  \n>  static const char *const repo_usage[] = {\n>  \t\"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\",\n> -\t\"git repo structure [--format=(table|keyvalue|nul)]\",\n> +\t\"git repo structure [--format=(table|keyvalue|nul)] [-z]\",\n>  \tNULL\n>  };\n>  \n> @@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,\n>  \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n>  \t\t\t       N_(\"output format\"),\n>  \t\t\t       PARSE_OPT_NONEG, parse_format_cb),\n> +\t\tOPT_CALLBACK_F('z', NULL, &format, NULL,\n> +\t\t\t       N_(\"synonym for --format=nul\"),\n> +\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n> +\t\t\t       parse_format_cb),\n\nReusing the same `parse_format_cb()` makes sense and also matches what\nwe do with git-repo-info. Looks good.\n\n>  \t\tOPT_BOOL(0, \"progress\", &show_progress, N_(\"show progress\")),\n>  \t\tOPT_END()\n>  \t};\n> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\n> index 36a71a144e..5a50acf345 100755\n> --- a/t/t1901-repo-structure.sh\n> +++ b/t/t1901-repo-structure.sh\n> @@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '\n>  \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n>  \t\tgit repo structure --format=nul >out 2>err &&\n>  \n> +\t\ttest_cmp expect_nul out &&\n> +\t\ttest_line_count = 0 err &&\n> +\n> +\t\t# Check -z\n> +\t\tgit repo structure --format=nul >out 2>err &&\n\nDid you mean to use the -z option here?\n\n-Justin\n"},{"id":"531529","messageId":"2EF2A8F3-93A7-499C-9307-413CBFB0C4D5@gmail.com","threadId":"64559","inReplyTo":"3hzpywampwjfsckljdqhyabhkupqmrzbcsc7fhrkg2cl4rjzzm@mygtkda7soxj","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-02T00:29:59Z","receivedAt":"2025-12-02T00:30:14Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\n>> This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)\n>> with lo/repo-info-all merged.\n> \n> Any reason this isn't just based on master? It looks like this patch\n> should apply just fine as I don't see any dependencies.\n\nYesterday, lo/repo-info-all wasn't merged yet to master :-)\n\n> Reusing the same `parse_format_cb()` makes sense and also matches what\n> we do with git-repo-info. Looks good.\n\nYes, this callback is used by both subcommands, this was a really\nstraightforward change.\n\n> Did you mean to use the -z option here?\n\nOoops, yes, sorry. I'll fix it.\n\n\n"},{"id":"531536","messageId":"xmqqsedt8s3g.fsf@gitster.g","threadId":"64559","inReplyTo":"aS1Rvy9J2KjWrQb4@pks.im","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-02T03:45:07Z","receivedAt":"2025-12-02T03:45:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> I think this ultimately stems from [2], where you argue that it _is_\n> possible to say `git repo info --format=table -z`, and the last option\n> wins. It's the same for `git repo structure`, so I'd argue we should be\n> consistent.\n\nI do not think so; [2] was about the explicit \"--format=nul and -z\nare incompatible\" code.  Even without this '-z\" thing, if you have\n\n    [--opt=(a|b|c)]\n\nI _think_ our intention is to allow \"git cmd --opt=a --opt=b\" from\nthe user and let the last one win.  If you add \"-z\",\n\n    [--format=(table|keyvalue|nul)] [-z]\n    [--format=(table|keyvalue|nul) | -z]\n\nI think both would mean the same thing; I just was wonering if\ngrouping them together in one bracket makes it more obvious that\nthese are all options to control the output format.\n\nThere was also an inquiry about writing it like\n\n    [(--format=(table|keyvalue|nul) | -z)]\n\nor even\n\n    [(--format=(table|keyvalue|nul) | -z)...]\n\nas these can be repeated and let the last-one-wins rule decide the\nfinal outcome, but we do not do that.  I thought the final comment\non this was in\n\nhttps://lore.kernel.org/git/6186055.lOV4Wx5bFT@cayenne/\n\nwhere the message said\n\n    In fact the correct formatting is:\n\n    [--format=(keyvalue|nul) | -z] [<key>...]\n\n    As stated in \"CodingGuidelines:\n\n     Use spacing around \"|\" token(s), but not immediately after opening or\n     before closing a [] or () pair:\n       Do: [-q | --quiet]\n       Don't: [-q|--quiet]\n\n     Don't use spacing around \"|\" tokens when they're used to separate the\n     alternate arguments of an option:\n        Do: --track[=(direct|inherit)]\n        Don't: --track[=(direct | inherit)]\n\nand that was where the thread ended, I think.\n\n> [1]: <20250820144247.79197-1-lucasseikioshiro@gmail.com>\n> [2]: <xmqqcy8frqn2.fsf@gitster.g>\n"},{"id":"531587","messageId":"D71DC18C-03CF-49A3-8833-DED7E326344B@gmail.com","threadId":"64559","inReplyTo":"xmqqsedt8s3g.fsf@gitster.g","subject":"Re: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-02T22:05:49Z","receivedAt":"2025-12-02T22:06:04Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> I thought the final comment on this was in\n> \n> https://lore.kernel.org/git/6186055.lOV4Wx5bFT@cayenne/\n\nActually, the final comment was [1], after the version where I use\n`[--format=...] [-z]`. \n\nBut actually, I don't have a strong opinion on using `| -z` vs using\n`[-z]`, since both work here, but if `| -z` looks clearer, I can \nchange it in the next version. However, I'll do that for both\nrepo-info and repo-structure, since --format is parsed by the same\nfunction in both of them.\n\n[1]: <xmqqms7cltak.fsf@gitster.g <mailto:xmqqms7cltak.fsf@gitster.g>>\n"},{"id":"531674","messageId":"20251204210843.79411-1-lucasseikioshiro@gmail.com","threadId":"64559","inReplyTo":"20251130203456.28437-1-lucasseikioshiro@gmail.com","subject":"[PATCH v2 0/3] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-04T20:10:09Z","receivedAt":"2025-12-04T21:09:37Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThe main objective of this patchset is to add -z to git-repo-structure as\nan alias for --format=nul. I'm including two other related patches here:\n\n- a patch removing an extra line in the documentation, which was leaking an + to\n  the generated files\n\n- a patch replacing `[--format=...] [-z]` by `[--format=... | -z]` in\n  git-repo-info's synopsis\n\nLucas Seiki Oshiro (3):\n  repo: remove blank line from Documentation/git-repo.adoc\n  repo: use [--format=... | -z] instead of [-z] in git-repo-info\n    synopsis\n  repo: add -z as an alias for --format=nul to git-repo-structure\n\n Documentation/git-repo.adoc | 11 ++++++-----\n builtin/repo.c              |  8 ++++++--\n t/t1901-repo-structure.sh   |  7 +++++++\n 3 files changed, 19 insertions(+), 7 deletions(-)\n\nRange-diff against v1:\n-:  ---------- > 1:  bfd4ff5db0 repo: remove blank line from Documentation/git-repo.adoc\n-:  ---------- > 2:  e5eac8713c repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis\n1:  f051cd41de ! 3:  0ccec7037d repo: add -z as an alias for --format=nul to git-repo-structure\n    @@ Documentation/git-repo.adoc\n     @@ Documentation/git-repo.adoc: SYNOPSIS\n      --------\n      [synopsis]\n    - git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n    + git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\n     -git repo structure [--format=(table|keyvalue|nul)]\n    -+git repo structure [--format=(table|keyvalue|nul)] [-z]\n    ++git repo structure [--format=(table|keyvalue|nul) | -z]\n      \n      DESCRIPTION\n      -----------\n    @@ Documentation/git-repo.adoc: supported:\n      `-z` is an alias for `--format=nul`.\n      \n     -`structure [--format=(table|keyvalue|nul)]`::\n    -+`structure [--format=(table|keyvalue|nul)] [-z]`::\n    ++`structure [--format=(table|keyvalue|nul) | -z]`::\n      \tRetrieve statistics about the current repository structure. The\n      \tfollowing kinds of information are reported:\n      +\n    @@ Documentation/git-repo.adoc: supported:\n      \tthe delimiter between the key and value instead of '='. Unlike the\n      \t`keyvalue` format, values containing \"unusual\" characters are never\n      \tquoted.\n    +++\n     +`-z` is an alias for `--format=nul`.\n      \n      INFO KEYS\n    @@ builtin/repo.c\n     @@\n      \n      static const char *const repo_usage[] = {\n    - \t\"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\",\n    + \t\"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\",\n     -\t\"git repo structure [--format=(table|keyvalue|nul)]\",\n    -+\t\"git repo structure [--format=(table|keyvalue|nul)] [-z]\",\n    ++\t\"git repo structure [--format=(table|keyvalue|nul) | -z]\",\n      \tNULL\n      };\n      \n    @@ t/t1901-repo-structure.sh: test_expect_success 'keyvalue and nul format' '\n     +\t\ttest_cmp expect_nul out &&\n     +\t\ttest_line_count = 0 err &&\n     +\n    -+\t\t# Check -z\n    -+\t\tgit repo structure --format=nul >out 2>err &&\n    ++\t\t# \"-z\", as a synonym to \"--format=nul\", participates in the\n    ++\t\t# usual \"last one wins\" rule.\n    ++\t\tgit repo structure --format=table -z >out 2>err &&\n     +\n      \t\ttest_cmp expect_nul out &&\n      \t\ttest_line_count = 0 err\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"531675","messageId":"20251204210843.79411-2-lucasseikioshiro@gmail.com","threadId":"64559","inReplyTo":"20251204210843.79411-1-lucasseikioshiro@gmail.com","subject":"[PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-04T20:10:10Z","receivedAt":"2025-12-04T21:09:39Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"There was an extra blank line in git-repo-structure documentation, which\nled to an unwawnted '+' character after generating an HTML or PDF from\nthat page. This can be seen, for example, in Git 2.52.0 online docs [1].\n\nRemove that extra line.\n\n[1] https://git-scm.com/docs/git-repo/2.52.0\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 70f0a6d2e4..5d9c7641c2 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -50,7 +50,6 @@ supported:\n +\n * Reference counts categorized by type\n * Reachable object counts categorized by type\n-\n +\n The output format can be chosen through the flag `--format`. Three formats are\n supported:\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"531676","messageId":"20251204210843.79411-3-lucasseikioshiro@gmail.com","threadId":"64559","inReplyTo":"20251204210843.79411-1-lucasseikioshiro@gmail.com","subject":"[PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-04T20:10:11Z","receivedAt":"2025-12-04T21:09:40Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"The flag -z is only an alias for --format=null and even though --format\nand -z can be used together and repeated, only the last one is\nconsidered.\n\nReplace `[-z]` in the synopsis of git-repo-info by\n`[--format=... | -z]`, expliciting that the use of one of those flags\nreplace the other.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 4 ++--\n builtin/repo.c              | 2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 5d9c7641c2..f24514deaa 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -8,7 +8,7 @@ git-repo - Retrieve information about the repository\n SYNOPSIS\n --------\n [synopsis]\n-git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n+git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\n git repo structure [--format=(table|keyvalue|nul)]\n \n DESCRIPTION\n@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [-z] [--all | <key>...]`::\n+`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::\n \tRetrieve metadata-related information about the current repository. Only\n \tthe requested data will be returned based on their keys (see \"INFO KEYS\"\n \tsection below).\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 2a653bd3ea..cc97dd1836 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -15,7 +15,7 @@\n #include \"utf8.h\"\n \n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\",\n \t\"git repo structure [--format=(table|keyvalue|nul)]\",\n \tNULL\n };\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"531677","messageId":"20251204210843.79411-4-lucasseikioshiro@gmail.com","threadId":"64559","inReplyTo":"20251204210843.79411-1-lucasseikioshiro@gmail.com","subject":"[PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-04T20:10:12Z","receivedAt":"2025-12-04T21:09:42Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Other Git commands that have nul-terminated output, such as git-config,\ngit-status, git-ls-files, and git-repo-info have a flag `-z` for using\nthe null character as the record separator.\n\nAdd the `-z` flag to git-repo-structure as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 6 ++++--\n builtin/repo.c              | 6 +++++-\n t/t1901-repo-structure.sh   | 7 +++++++\n 3 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex f24514deaa..c4a78277df 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -9,7 +9,7 @@ SYNOPSIS\n --------\n [synopsis]\n git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\n-git repo structure [--format=(table|keyvalue|nul)]\n+git repo structure [--format=(table|keyvalue|nul) | -z]\n \n DESCRIPTION\n -----------\n@@ -44,7 +44,7 @@ supported:\n +\n `-z` is an alias for `--format=nul`.\n \n-`structure [--format=(table|keyvalue|nul)]`::\n+`structure [--format=(table|keyvalue|nul) | -z]`::\n \tRetrieve statistics about the current repository structure. The\n \tfollowing kinds of information are reported:\n +\n@@ -71,6 +71,8 @@ supported:\n \tthe delimiter between the key and value instead of '='. Unlike the\n \t`keyvalue` format, values containing \"unusual\" characters are never\n \tquoted.\n++\n+`-z` is an alias for `--format=nul`.\n \n INFO KEYS\n ---------\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex cc97dd1836..0dd41b1778 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -16,7 +16,7 @@\n \n static const char *const repo_usage[] = {\n \t\"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]\",\n-\t\"git repo structure [--format=(table|keyvalue|nul)]\",\n+\t\"git repo structure [--format=(table|keyvalue|nul) | -z]\",\n \tNULL\n };\n \n@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n \t\t\t       PARSE_OPT_NONEG, parse_format_cb),\n+\t\tOPT_CALLBACK_F('z', NULL, &format, NULL,\n+\t\t\t       N_(\"synonym for --format=nul\"),\n+\t\t\t       PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n+\t\t\t       parse_format_cb),\n \t\tOPT_BOOL(0, \"progress\", &show_progress, N_(\"show progress\")),\n \t\tOPT_END()\n \t};\ndiff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\nindex 36a71a144e..df7d4ea524 100755\n--- a/t/t1901-repo-structure.sh\n+++ b/t/t1901-repo-structure.sh\n@@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' '\n \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n \t\tgit repo structure --format=nul >out 2>err &&\n \n+\t\ttest_cmp expect_nul out &&\n+\t\ttest_line_count = 0 err &&\n+\n+\t\t# \"-z\", as a synonym to \"--format=nul\", participates in the\n+\t\t# usual \"last one wins\" rule.\n+\t\tgit repo structure --format=table -z >out 2>err &&\n+\n \t\ttest_cmp expect_nul out &&\n \t\ttest_line_count = 0 err\n \t)\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"531689","messageId":"aTK9X6ptrqs_9agD@pks.im","threadId":"64559","inReplyTo":"20251204210843.79411-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v2 0/3] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-12-05T11:09:19Z","receivedAt":"2025-12-05T11:09:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Dec 04, 2025 at 05:10:09PM -0300, Lucas Seiki Oshiro wrote:\n> Hi!\n> \n> The main objective of this patchset is to add -z to git-repo-structure as\n> an alias for --format=nul. I'm including two other related patches here:\n> \n> - a patch removing an extra line in the documentation, which was leaking an + to\n>   the generated files\n> \n> - a patch replacing `[--format=...] [-z]` by `[--format=... | -z]` in\n>   git-repo-info's synopsis\n\nThis version looks good to me, thanks!\n\nPatrick\n"},{"id":"532016","messageId":"xmqqh5txfv7b.fsf@gitster.g","threadId":"64559","inReplyTo":"20251204210843.79411-4-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-11T05:23:20Z","receivedAt":"2025-12-11T05:23:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n\n> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh\n> index 36a71a144e..df7d4ea524 100755\n> --- a/t/t1901-repo-structure.sh\n> +++ b/t/t1901-repo-structure.sh\n> @@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' '\n>  \t\ttr \"\\n=\" \"\\0\\n\" <expect >expect_nul &&\n>  \t\tgit repo structure --format=nul >out 2>err &&\n> +\t\ttest_cmp expect_nul out &&\n> +\t\ttest_line_count = 0 err &&\n\nNot limited to this step, but I have a couple of comments.\n\n * Instead of munging the expected file so that it contains a NUL,\n   and compare the actual output with it, munge the NUL terminated\n   outout to make it text and compare with the expected file in text\n   format.  This matters when tests start to fail as test_cmp will\n   show the \"diff\" output when it fails, and comparing NUL\n   terminated files, which are \"binary\" in the eyes of the \"diff\"\n   utility.\n\n * I see your -z output is \"<key> LF <value> NUL\", but was there a\n   particular reason why \"<key> NUL <value> NUL\" was not chosen?\n   Unless there is a compelling reason not to, it would be a lot\n   more future-proof to use NUL for both, primarily because it would\n   allow future developers to include arbitrary non-NUL bytes in the\n   <key> part in the future (and we wouldn't know what end-user\n   controlled substring they may want to add).\n\n> +\n> +\t\t# \"-z\", as a synonym to \"--format=nul\", participates in the\n> +\t\t# usual \"last one wins\" rule.\n> +\t\tgit repo structure --format=table -z >out 2>err &&\n> +\n>  \t\ttest_cmp expect_nul out &&\n>  \t\ttest_line_count = 0 err\n>  \t)\n"},{"id":"532503","messageId":"5240C85D-7587-4042-AA75-58356BCFF351@gmail.com","threadId":"64559","inReplyTo":"xmqqh5txfv7b.fsf@gitster.g","subject":"Re: [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-12-18T23:02:41Z","receivedAt":"2025-12-18T23:02:50Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi, Junio!\n\n> * Instead of munging the expected file so that it contains a NUL,\n>   and compare the actual output with it, munge the NUL terminated\n>   outout to make it text and compare with the expected file in text\n>   format.\n\nOk! I'll do that in the next version.\n\n> * I see your -z output is \"<key> LF <value> NUL\", but was there a\n>   particular reason why \"<key> NUL <value> NUL\" was not chosen?\n\nThis was a suggestions by Phillip Wood [1]. We've chosen this format\nfollowing the format of git-config.\n\n[1] https://lore.kernel.org/git/223c7cbd-610e-49e2-90e2-5914cbc0f1d7@gmail.com/\n\n"}]}