{"thread":{"id":"63995","subject":"[GSoC PATCH 0/2] repo: add -z and objects.format","startedAt":"2025-08-20T14:43:49Z","lastAt":"2025-09-04T18:40:05Z","messageCount":37,"participants":["Lucas Seiki Oshiro","Karthik Nayak","Patrick Steinhardt","Junio C Hamano","Jean-Noël AVILA"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"524528","messageId":"20250820144247.79197-1-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":null,"subject":"[GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-20T14:42:45Z","receivedAt":"2025-08-20T14:43:49Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThis patchset adds two features to `git repo info`. They are unrelated,\nbut I preferred to send them together to avoid merge conflicts and\nbecause they are small.\n\n- The first patch adds the `-z` as an alias for `--format=null`, as\n  requested in [1]\n\n- The second patch adds `objects.format`, which retrieves the same value\n  as `git rev-parse --show-object-format`\n  \nThanks!\n\n[1] https://lore.kernel.org/git/mgdervgp34m6ipfbodsfn7cztcl7gdeggzemfgivzvuyk7qtba@wdijebkuioxg/\n\nLucas Seiki Oshiro (2):\n  repo: add the flag -z as an alias for --format=nul\n  repo: add the field objects.format\n\n Documentation/git-repo.adoc |  9 +++++++--\n builtin/repo.c              | 24 +++++++++++++++++++-----\n t/t1900-repo.sh             | 18 ++++++++++++++++++\n 3 files changed, 44 insertions(+), 7 deletions(-)\n\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"524529","messageId":"20250820144247.79197-2-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-20T14:42:46Z","receivedAt":"2025-08-20T14:43:51Z","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 (e.g. git-config,\ngit-status, git-ls-files) have a flag `-z` for using the null character\nas the record separator.\n\nAdd the `-z` flag to git-repo-info as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc |  6 ++++--\n builtin/repo.c              | 17 ++++++++++++-----\n t/t1900-repo.sh             | 12 ++++++++++++\n 3 files changed, 28 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 2870828d93..f2dc71193c 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)] [<key>...]\n+git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n \n DESCRIPTION\n -----------\n@@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [<key>...]`::\n+`info [--format=(keyvalue|nul)|-z] [<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).\n@@ -40,6 +40,8 @@ supported:\n \tbetween the key and the value and using a NUL character after each value.\n \tThis format is better suited for being parsed by another applications than\n \t`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.\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 8c6e7f42ab..b2ec66e454 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -9,7 +9,7 @@\n #include \"shallow.h\"\n \n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul)|-z] [<key>...]\",\n \tNULL\n };\n \n@@ -115,20 +115,27 @@ static int print_fields(int argc, const char **argv,\n static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n-\tconst char *format_str = \"keyvalue\";\n+\tconst char *format_str = NULL;\n \tenum output_format format;\n+\tint format_nul = 0;\n \tstruct option options[] = {\n \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n \t\t\t   N_(\"output format\")),\n+\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n \t\tOPT_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n-\tif (!strcmp(format_str, \"keyvalue\"))\n-\t\tformat = FORMAT_KEYVALUE;\n-\telse if (!strcmp(format_str, \"nul\"))\n+\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n+\t\t\t\t  !!format_str, \"--format\");\n+\n+\tformat_str = format_str ? format_str : \"keyvalue\";\n+\n+\tif (format_nul || !strcmp(format_str, \"nul\"))\n \t\tformat = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(format_str, \"keyvalue\"))\n+\t\tformat = FORMAT_KEYVALUE;\n \telse\n \t\tdie(_(\"invalid format '%s'\"), format_str);\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex a69c715357..3df55dcc79 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -92,4 +92,16 @@ test_expect_success 'git-repo-info aborts when requesting an invalid format' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '-z uses nul-terminated format' '\n+\tprintf \"layout.bare\\nfalse\\0layout.shallow\\nfalse\\0\" >expected &&\n+\tgit repo info -z layout.bare layout.shallow >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git repo info fails when using --format and -z' '\n+\techo \"fatal: options ${SQ}-z${SQ} and ${SQ}--format${SQ} cannot be used together\" >expected &&\n+\ttest_must_fail git repo info -z --format=keyvalue 2>actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"524530","messageId":"20250820144247.79197-3-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH 2/2] repo: add the field objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-20T14:42:47Z","receivedAt":"2025-08-20T14:43:53Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"The flag `--show-object-format` from git-rev-parse is used for\nretrieving the object storage format. This way, it is used for\nquerying repository metadata, fitting in the purpose of git-repo-info.\n\nAdd a new field `objects.format` to the git-repo-info subcommand\ncontaining that information.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 3 +++\n builtin/repo.c              | 7 +++++++\n t/t1900-repo.sh             | 6 ++++++\n 3 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex f2dc71193c..b6ec423d12 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -55,6 +55,9 @@ values that they return:\n `layout.shallow`::\n \t`true` if this is a shallow repository, otherwise `false`.\n \n+`objects.format`::\n+\tThe object format (hash algorithm) used in the repository.\n+\n `references.format`::\n \tThe reference storage format. The valid values are:\n +\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex b2ec66e454..71ddc5e8c6 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -38,6 +38,12 @@ static int get_layout_shallow(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_objects_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->hash_algo->name);\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf)\n {\n \tstrbuf_addstr(buf,\n@@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n static const struct field repo_info_fields[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n+\t{ \"objects.format\", get_objects_format},\n \t{ \"references.format\", get_references_format },\n };\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 3df55dcc79..aca2ed23f9 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -63,6 +63,12 @@ test_expect_success 'setup remote' '\n test_repo_info 'shallow repository = true is retrieved correctly' \\\n \t'git clone --depth 1 \"file://$PWD/remote\"' 'shallow' 'layout.shallow' 'true'\n \n+test_repo_info 'objects.format = sha1 is retrieved correctly' \\\n+\t'git init --object-format=sha1' 'sha1' 'objects.format' 'sha1'\n+\n+test_repo_info 'objects.format = sha256 is retrieved correctly' \\\n+\t'git init --object-format=sha256' 'sha256' 'objects.format' 'sha256'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"524636","messageId":"CAOLa=ZQZCUsa7M0mh1oCq8hhBZS05=jw4y2Lr1r3rPe0-ajbhw@mail.gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-2-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-08-21T10:12:17Z","receivedAt":"2025-08-21T10:12:20Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n\n> Other Git commands that have nul-terminated output (e.g. git-config,\n> git-status, git-ls-files) have a flag `-z` for using the null character\n> as the record separator.\n>\n> Add the `-z` flag to git-repo-info as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n>\n> Mentored-by: Karthik Nayak <karthik.188@gmail.com>\n> Mentored-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n>  Documentation/git-repo.adoc |  6 ++++--\n>  builtin/repo.c              | 17 ++++++++++++-----\n>  t/t1900-repo.sh             | 12 ++++++++++++\n>  3 files changed, 28 insertions(+), 7 deletions(-)\n>\n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index 2870828d93..f2dc71193c 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)] [<key>...]\n> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n>\n\nNit: Perhaps we can leave a space around '|' to make it easier to read?\n\n>  DESCRIPTION\n>  -----------\n> @@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n>\n>  COMMANDS\n>  --------\n> -`info [--format=(keyvalue|nul)] [<key>...]`::\n> +`info [--format=(keyvalue|nul)|-z] [<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).\n> @@ -40,6 +40,8 @@ supported:\n>  \tbetween the key and the value and using a NUL character after each value.\n>  \tThis format is better suited for being parsed by another applications than\n>  \t`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.\n> ++\n> +`-z` is an alias for `--format=nul`.\n>\n>  INFO KEYS\n>  ---------\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 8c6e7f42ab..b2ec66e454 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -9,7 +9,7 @@\n>  #include \"shallow.h\"\n>\n>  static const char *const repo_usage[] = {\n> -\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n> +\t\"git repo info [--format=(keyvalue|nul)|-z] [<key>...]\",\n>  \tNULL\n>  };\n>\n> @@ -115,20 +115,27 @@ static int print_fields(int argc, const char **argv,\n>  static int repo_info(int argc, const char **argv, const char *prefix,\n>  \t\t     struct repository *repo)\n>  {\n> -\tconst char *format_str = \"keyvalue\";\n> +\tconst char *format_str = NULL;\n>  \tenum output_format format;\n> +\tint format_nul = 0;\n>  \tstruct option options[] = {\n>  \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n>  \t\t\t   N_(\"output format\")),\n> +\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n>  \t\tOPT_END()\n>  \t};\n>\n>  \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>\n> -\tif (!strcmp(format_str, \"keyvalue\"))\n> -\t\tformat = FORMAT_KEYVALUE;\n> -\telse if (!strcmp(format_str, \"nul\"))\n> +\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n> +\t\t\t\t  !!format_str, \"--format\");\n> +\n> +\tformat_str = format_str ? format_str : \"keyvalue\";\n> +\n> +\tif (format_nul || !strcmp(format_str, \"nul\"))\n>  \t\tformat = FORMAT_NUL_TERMINATED;\n> +\telse if (!strcmp(format_str, \"keyvalue\"))\n> +\t\tformat = FORMAT_KEYVALUE;\n>  \telse\n>  \t\tdie(_(\"invalid format '%s'\"), format_str);\n>\n> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\n> index a69c715357..3df55dcc79 100755\n> --- a/t/t1900-repo.sh\n> +++ b/t/t1900-repo.sh\n> @@ -92,4 +92,16 @@ test_expect_success 'git-repo-info aborts when requesting an invalid format' '\n>  \ttest_cmp expect actual\n>  '\n>\n> +test_expect_success '-z uses nul-terminated format' '\n> +\tprintf \"layout.bare\\nfalse\\0layout.shallow\\nfalse\\0\" >expected &&\n> +\tgit repo info -z layout.bare layout.shallow >actual &&\n> +\ttest_cmp expected actual\n> +'\n> +\n> +test_expect_success 'git repo info fails when using --format and -z' '\n> +\techo \"fatal: options ${SQ}-z${SQ} and ${SQ}--format${SQ} cannot be used together\" >expected &&\n> +\ttest_must_fail git repo info -z --format=keyvalue 2>actual &&\n> +\ttest_cmp expected actual\n> +'\n> +\n>  test_done\n> --\n> 2.39.5 (Apple Git-154)\n\nThe rest looks good.\n"},{"id":"524637","messageId":"CAOLa=ZQkV6FXCocVFdBoxbR_0eioQeY3hkOGOke+XWciLeZ+PA@mail.gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-08-21T10:14:10Z","receivedAt":"2025-08-21T10:14:12Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n\n> Hi!\n>\n> This patchset adds two features to `git repo info`. They are unrelated,\n> but I preferred to send them together to avoid merge conflicts and\n> because they are small.\n>\n> - The first patch adds the `-z` as an alias for `--format=null`, as\n>   requested in [1]\n>\n> - The second patch adds `objects.format`, which retrieves the same value\n>   as `git rev-parse --show-object-format`\n>\n> Thanks!\n>\n\nJust a tip: It would be nice to mention which base branch this is based\non top of and dependencies.\n\nThe patches themselves look good to me, just a small nit on the first\ncommit.\n\nThanks!\n\n[snip]\n"},{"id":"524641","messageId":"aKb1AfeIWB_SfJiI@pks.im","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-08-21T10:29:21Z","receivedAt":"2025-08-21T10:29:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Aug 20, 2025 at 11:42:45AM -0300, Lucas Seiki Oshiro wrote:\n> Hi!\n> \n> This patchset adds two features to `git repo info`. They are unrelated,\n> but I preferred to send them together to avoid merge conflicts and\n> because they are small.\n> \n> - The first patch adds the `-z` as an alias for `--format=null`, as\n>   requested in [1]\n> \n> - The second patch adds `objects.format`, which retrieves the same value\n>   as `git rev-parse --show-object-format`\n>   \n> Thanks!\n> \n> [1] https://lore.kernel.org/git/mgdervgp34m6ipfbodsfn7cztcl7gdeggzemfgivzvuyk7qtba@wdijebkuioxg/\n\nWhat this cover letter doesn't mention is the base of the topic. I\nassume it's v2.51.0 with lo/repo-info merged into it?\n\nPatrick\n"},{"id":"524642","messageId":"aKb1BjPfmjBvHrm0@pks.im","threadId":"63995","inReplyTo":"20250820144247.79197-2-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-08-21T10:29:26Z","receivedAt":"2025-08-21T10:29:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Aug 20, 2025 at 11:42:46AM -0300, Lucas Seiki Oshiro wrote:\n> Other Git commands that have nul-terminated output (e.g. git-config,\n> git-status, git-ls-files) have a flag `-z` for using the null character\n> as the record separator.\n> \n> Add the `-z` flag to git-repo-info as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n\nYeah, it's common indeed to have `-z` for nul-terminated output.\n\n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index 2870828d93..f2dc71193c 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)] [<key>...]\n> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n\nNot a 100% sure, but I think this would actually need to be formatted as\n\n    [(--format=(keyvalue|nul)|-z)]\n\nLooks a bit ugly though, so maybe the existent version is good enough?\nOthers may have a more informed opinion.\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 8c6e7f42ab..b2ec66e454 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -115,20 +115,27 @@ static int print_fields(int argc, const char **argv,\n>  static int repo_info(int argc, const char **argv, const char *prefix,\n>  \t\t     struct repository *repo)\n>  {\n> -\tconst char *format_str = \"keyvalue\";\n> +\tconst char *format_str = NULL;\n>  \tenum output_format format;\n> +\tint format_nul = 0;\n>  \tstruct option options[] = {\n>  \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n>  \t\t\t   N_(\"output format\")),\n> +\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n>  \t\tOPT_END()\n>  \t};\n>  \n>  \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>  \n> -\tif (!strcmp(format_str, \"keyvalue\"))\n> -\t\tformat = FORMAT_KEYVALUE;\n> -\telse if (!strcmp(format_str, \"nul\"))\n> +\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n> +\t\t\t\t  !!format_str, \"--format\");\n\nMakes sense, we only want one of \"--format=\" or \"-z\".\n\n> +\tformat_str = format_str ? format_str : \"keyvalue\";\n> +\n> +\tif (format_nul || !strcmp(format_str, \"nul\"))\n>  \t\tformat = FORMAT_NUL_TERMINATED;\n> +\telse if (!strcmp(format_str, \"keyvalue\"))\n> +\t\tformat = FORMAT_KEYVALUE;\n>  \telse\n>  \t\tdie(_(\"invalid format '%s'\"), format_str);\n>  \n\nAnd here we then determine which format was picked. Looks reasonable.\n\nPatrick\n"},{"id":"524643","messageId":"aKb1Cw-SuS2t0CqG@pks.im","threadId":"63995","inReplyTo":"20250820144247.79197-3-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 2/2] repo: add the field objects.format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-08-21T10:29:31Z","receivedAt":"2025-08-21T10:29:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Aug 20, 2025 at 11:42:47AM -0300, Lucas Seiki Oshiro wrote:\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index b2ec66e454..71ddc5e8c6 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n>  static const struct field repo_info_fields[] = {\n>  \t{ \"layout.bare\", get_layout_bare },\n>  \t{ \"layout.shallow\", get_layout_shallow },\n> +\t{ \"objects.format\", get_objects_format},\n\nThere's a missing space here before the closing curly brace. Other than\nthat this patch looks good to me.\n\nThanks!\n\nPatrick\n"},{"id":"524656","messageId":"2AE1A298-97D9-411A-A3B4-AB0A48D71536@gmail.com","threadId":"63995","inReplyTo":"aKb1AfeIWB_SfJiI@pks.im","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-21T13:23:29Z","receivedAt":"2025-08-21T13:23:43Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> What this cover letter doesn't mention is the base of the topic. I\n> assume it's v2.51.0 with lo/repo-info merged into it?\n\nI was assuming next, but I'll make it more clear in the next\nversion.\n\n"},{"id":"524657","messageId":"65E661E9-B926-4EC1-B0EC-CDE2CD1557E5@gmail.com","threadId":"63995","inReplyTo":"aKb1BjPfmjBvHrm0@pks.im","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-21T13:29:19Z","receivedAt":"2025-08-21T13:29:34Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> Not a 100% sure, but I think this would actually need to be formatted as\n> \n>    [(--format=(keyvalue|nul)|-z)]\n> \n> Looks a bit ugly though, so maybe the existent version is good enough?\n> Others may have a more informed opinion.\n\nI couldn't find other usage strings following that syntax in Git (I tried\n`git grep '\\[[(].*|.*[)]\\]' -- 'Documentation/git-*.adoc'`).\n\nBut I don't have any strong opinion about that. I'm open to suggestions.\n\nThanks!\n\n"},{"id":"524659","messageId":"aKczWVw1HafaKZNW@pks.im","threadId":"63995","inReplyTo":"2AE1A298-97D9-411A-A3B4-AB0A48D71536@gmail.com","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-08-21T14:55:21Z","receivedAt":"2025-08-21T14:55:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Aug 21, 2025 at 10:23:29AM -0300, Lucas Seiki Oshiro wrote:\n> \n> > What this cover letter doesn't mention is the base of the topic. I\n> > assume it's v2.51.0 with lo/repo-info merged into it?\n> \n> I was assuming next, but I'll make it more clear in the next\n> version.\n\nYou shouldn't base your patch series on next, as next may be rewritten\nunder your feet and it would hold any patch series that you built on\nhostage.\n\nSo the recommendation is rather to build on `master` with the specific\npatch series you depend on merged into it.\n\nPatrick\n"},{"id":"524665","messageId":"xmqqsehk3bcp.fsf@gitster.g","threadId":"63995","inReplyTo":"CAOLa=ZQZCUsa7M0mh1oCq8hhBZS05=jw4y2Lr1r3rPe0-ajbhw@mail.gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T16:09:42Z","receivedAt":"2025-08-21T16:09:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n>> -git repo info [--format=(keyvalue|nul)] [<key>...]\n>> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n>>\n>\n> Nit: Perhaps we can leave a space around '|' to make it easier to read?\n\nDocumentation/CodingGuidelines (Synopsis Syntax) has explicit\nguidelines about these things.\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\n"},{"id":"524666","messageId":"xmqqo6s83b8u.fsf@gitster.g","threadId":"63995","inReplyTo":"CAOLa=ZQkV6FXCocVFdBoxbR_0eioQeY3hkOGOke+XWciLeZ+PA@mail.gmail.com","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T16:12:01Z","receivedAt":"2025-08-21T16:12:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n>\n>> Hi!\n>>\n>> This patchset adds two features to `git repo info`. They are unrelated,\n>> but I preferred to send them together to avoid merge conflicts and\n>> because they are small.\n>>\n>> - The first patch adds the `-z` as an alias for `--format=null`, as\n>>   requested in [1]\n>>\n>> - The second patch adds `objects.format`, which retrieves the same value\n>>   as `git rev-parse --show-object-format`\n>>\n>> Thanks!\n>>\n>\n> Just a tip: It would be nice to mention which base branch this is based\n> on top of and dependencies.\n\nA very good suggestion.  As this builds on top of lo/repo-info,\nwhich currently is at a81224d1 (repo: add the --format flag,\n2025-08-16), I queued on top of a merge of that topic into Git 2.51\n\nThanks.\n"},{"id":"524669","messageId":"CAOLa=ZQ3d6aDi5jH6A8xuwmdnk78fXq12pGxo+_WDN-0tNorkg@mail.gmail.com","threadId":"63995","inReplyTo":"xmqqsehk3bcp.fsf@gitster.g","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-08-21T16:52:22Z","receivedAt":"2025-08-21T16:52:49Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Thu, Aug 21, 2025 at 6:09 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> >> -git repo info [--format=(keyvalue|nul)] [<key>...]\n> >> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n> >>\n> >\n> > Nit: Perhaps we can leave a space around '|' to make it easier to read?\n>\n> Documentation/CodingGuidelines (Synopsis Syntax) has explicit\n> guidelines about these things.\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>\n\nI stand corrected, thanks!\n"},{"id":"524671","messageId":"xmqq8qjc37q4.fsf@gitster.g","threadId":"63995","inReplyTo":"2AE1A298-97D9-411A-A3B4-AB0A48D71536@gmail.com","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T17:28:03Z","receivedAt":"2025-08-21T17:28:06Z","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>> What this cover letter doesn't mention is the base of the topic. I\n>> assume it's v2.51.0 with lo/repo-info merged into it?\n>\n> I was assuming next, but I'll make it more clear in the next\n> version.\n\nLearn the way how it is usually done by looking at:\n\nhttps://lore.kernel.org/git/20250106-b4-pks-object-file-racy-collision-check-v2-0-8b3984ecbb18@pks.im/\n\nBasically you would want to say\n\n    This is built on top of <commit> with <topic*> merged into it.\n\nwhere <commit> is a commit on 'master' (or 'maint' or an even older\nmaintenance track, if the topic is about fixing a bug in a released\nversion of Git), and <topic*> are topic branches in flight that can\nbe merged to the same integration target ('master', or an older\nmaintenance tracks you chose <commit> from).  And keep the number of\n<topic*> to an absolute minimum in order for your changes to work.\n\nDo not build on 'next'.  You'll be taken hostage by all the other\ntopics and have to wait until all of them and the merge commits that\ndrew them into 'next' are merged to 'master', which will never\nhappen.\n\nThanks.\n"},{"id":"524672","messageId":"xmqq4iu037p1.fsf@gitster.g","threadId":"63995","inReplyTo":"65E661E9-B926-4EC1-B0EC-CDE2CD1557E5@gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T17:28:42Z","receivedAt":"2025-08-21T17:28:44Z","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> But I don't have any strong opinion about that. I'm open to suggestions.\n\nDon't ask for suggestions before consulting CodingGuidelines,\nperhaps?\n"},{"id":"524674","messageId":"6186055.lOV4Wx5bFT@cayenne","threadId":"63995","inReplyTo":"20250820144247.79197-2-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Jean-Noël AVILA","fromEmail":"jn.avila@free.fr","sentAt":"2025-08-21T18:23:58Z","receivedAt":"2025-08-21T18:24:17Z","isPatch":true,"sender":{"key":"jn.avila@free.fr","avatar":"https://avatars.githubusercontent.com/u/156172?v=4"},"body":"On Wednesday, 20 August 2025 16:42:46 CEST Lucas Seiki Oshiro wrote:\n> Other Git commands that have nul-terminated output (e.g. git-config,\n> git-status, git-ls-files) have a flag `-z` for using the null character\n> as the record separator.\n> \n> Add the `-z` flag to git-repo-info as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n> \n> Mentored-by: Karthik Nayak <karthik.188@gmail.com>\n> Mentored-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n>  Documentation/git-repo.adoc |  6 ++++--\n>  builtin/repo.c              | 17 ++++++++++++-----\n>  t/t1900-repo.sh             | 12 ++++++++++++\n>  3 files changed, 28 insertions(+), 7 deletions(-)\n> \n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index 2870828d93..f2dc71193c 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)] [<key>...]\n> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n> \n\nIn fact the correct formatting is:\n\n[--format=(keyvalue|nul) | -z] [<key>...]\n\nAs 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\n\n\n\n"},{"id":"524678","messageId":"xmqqh5y01mv3.fsf@gitster.g","threadId":"63995","inReplyTo":"20250820144247.79197-3-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH 2/2] repo: add the field objects.format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T19:44:00Z","receivedAt":"2025-08-21T19:44:03Z","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> The flag `--show-object-format` from git-rev-parse is used for\n> retrieving the object storage format. This way, it is used for\n> querying repository metadata, fitting in the purpose of git-repo-info.\n\nYes, and extensions.objectFormat specifies the hash algorithm used\nin the repository, extensions.compatObjectFormat specifies a\ncompatibility algorithm to use.  So objectFormat is a good name to\ncall this new \"repository metadata\".\n\n> Add a new field `objects.format` to the git-repo-info subcommand\n> containing that information.\n\nPerhaps drop \"s\" from \"objects.format\" before it becomes too late?\nWe may also want to reconsider references.format as that is not in\nline with either extensions.refStorage or --ref-format (taken by\n'git init' and 'git clone').\n\nDo these keys always have to be two words separated by dots?  I am\nasking if there are other keys that would plausibly fit next to this\nobject.format thing.  object.count to report how many objects there\nare in the repository, or things like that, perhaps?\n\n> @@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n>  static const struct field repo_info_fields[] = {\n>  \t{ \"layout.bare\", get_layout_bare },\n>  \t{ \"layout.shallow\", get_layout_shallow },\n> +\t{ \"objects.format\", get_objects_format},\n>  \t{ \"references.format\", get_references_format },\n>  };\n"},{"id":"524680","messageId":"xmqq5xeg1mgj.fsf@gitster.g","threadId":"63995","inReplyTo":"6186055.lOV4Wx5bFT@cayenne","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T19:52:44Z","receivedAt":"2025-08-21T19:52:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jean-Noël AVILA <jn.avila@free.fr> writes:\n\n>> -git repo info [--format=(keyvalue|nul)] [<key>...]\n>> +git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n>> \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\nYup, thanks!\n"},{"id":"524687","messageId":"7E449BB1-224F-4B15-BB0B-357E4FB79429@gmail.com","threadId":"63995","inReplyTo":"xmqq4iu037p1.fsf@gitster.g","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-21T20:57:04Z","receivedAt":"2025-08-21T20:57:18Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n>> But I don't have any strong opinion about that. I'm open to suggestions.\n> \n> Don't ask for suggestions before consulting CodingGuidelines,\n> perhaps?\n\nI think that Patrick was unsure about adding the external parentheses\nto make it look like [(--format=(keyvalue|nul) | -z)]. CodingGuideLines\nis not explicit about that specific case of having alternate flags\nwith nested alternate arguments, but I don't see a reason for using\nparentheses as it isn't ambiguous...\n"},{"id":"524688","messageId":"xmqqect4z6no.fsf@gitster.g","threadId":"63995","inReplyTo":"7E449BB1-224F-4B15-BB0B-357E4FB79429@gmail.com","subject":"Re: [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-21T21:50:03Z","receivedAt":"2025-08-21T21:50:06Z","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>>> But I don't have any strong opinion about that. I'm open to suggestions.\n>> \n>> Don't ask for suggestions before consulting CodingGuidelines,\n>> perhaps?\n>\n> I think that Patrick was unsure about adding the external parentheses\n> to make it look like [(--format=(keyvalue|nul) | -z)]. CodingGuideLines\n> is not explicit about that specific case of having alternate flags\n> with nested alternate arguments, but I don't see a reason for using\n> parentheses as it isn't ambiguous...\n\n Parentheses are used for grouping:\n   [(<rev>|<range>)...]\n   (Any number of either <rev> or <range>.  Parens are needed to make\n   it clear that \"...\" pertains to both <rev> and <range>.)\n\n   [(-p <parent>)...]\n   (Any number of option -p, each with one <parent> argument.)\n\nIf we were saying that these things can occur multiple times, it may\nbenefit from such a grouping by doing\n\n    [(--format=(keyvalue|nul) | -z)...]\n\nBut the outer () without these extra things, i.e.\n\n    [(--format=(keyvalue|nul) | -z)]\n\ndoes not look like serving any useful purpose at all to me...\n"},{"id":"524957","messageId":"261E9FC0-EE4A-4B4B-BA21-69B93EBA6933@gmail.com","threadId":"63995","inReplyTo":"xmqqh5y01mv3.fsf@gitster.g","subject":"Re: [GSoC PATCH 2/2] repo: add the field objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-26T14:51:25Z","receivedAt":"2025-08-26T14:51:40Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> Yes, and extensions.objectFormat specifies the hash algorithm used\n> in the repository, extensions.compatObjectFormat specifies a\n> compatibility algorithm to use.  So objectFormat is a good name to\n> call this new \"repository metadata\".\n\nI was discussing with Patrick some weeks ago about the compatibility\nformats. By now, the \"storage\", \"input\", and \"output\" formats are\nthe same. For example, rev-parse already has those options, even \nthough they return the same value (2eabd38313 (rev-parse: add a\n--show-object-format option, 2019-10-28)).\n\nRepo info is easy to handle this situation in the future by just\nadding a new field. By now, objects.format returns the storage\nformat. If/when we have those formats implemented, I think a good\napproach would be add two more values to `objects`:\n\nobjects.input-format=...\nobjects.output-format=...\n\n\n> Perhaps drop \"s\" from \"objects.format\" before it becomes too late?\n\nOk!\n\n> We may also want to reconsider references.format as that is not in\n> line with either extensions.refStorage or --ref-format (taken by\n> 'git init' and 'git clone').\n\nWhat would be a better name? reference.format or ref.format? \n\n> Do these keys always have to be two words separated by dots?\n\nThe idea is to group everything into categories, than it will be\neasier. I have a future feature planned for that one could call,\nfor example, `git repo layout` and then it will return both\nlayout.bare and layout.shallow. \n\n> I am asking if there are other keys that would plausibly fit next to this\n> object.format thing.  object.count to report how many objects there\n> are in the repository, or things like that, perhaps?\n\n\nGiven that it would survey how many objects exist in the repository,\nthis would be better placed in the planned `git repo survey` that\nJustin is working on (we discussed a little more about that in \nhttps://lore.kernel.org/git/vygdkwopfzrbdpxpxebnq3xdlg3ow4i3w5y5evduae2zuelqcn@la2dikht2qrf/\n). I'm cc'ing Justin here for more info about it.\n\nIn the `info` side, by now I don't remember any other key to be placed\nunder `object` aside from the aforementioned input and output format.\nPerhaps an idea is whether we're using packfiles or only loose objects,\nbut I don't know if it would be useful.\n\nThanks!"},{"id":"524986","messageId":"8EB9C032-6739-48F2-9097-9833FC3CAA28@gmail.com","threadId":"63995","inReplyTo":"xmqq8qjc37q4.fsf@gitster.g","subject":"Re: [GSoC PATCH 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-26T18:13:55Z","receivedAt":"2025-08-26T18:14:09Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> Basically you would want to say\n> \n>    This is built on top of <commit> with <topic*> merged into it.\n\nThanks!\n\nBut given that lo/repo-info was already merged to master, now\nit won't be necessary... But I'll be more clear about that in\nfuture patches.\n"},{"id":"524987","messageId":"20250826183205.19566-1-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v2 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-26T18:32:03Z","receivedAt":"2025-08-26T18:32:12Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThis v2 contains small fixes pointed in the last version:\n\n1. Adding two extra spaces in the usage string\n\n2. Use `object.format` instead of `objects.format`\n\nHere's the range-diff versus v1:\n\n1:  4cb193f59c ! 1:  3ea40b1572 repo: add the flag -z as an alias for --format=nul\n    @@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor\n      --------\n      [synopsis]\n     -git repo info [--format=(keyvalue|nul)] [<key>...]\n    -+git repo info [--format=(keyvalue|nul)|-z] [<key>...]\n    ++git repo info [--format=(keyvalue|nul) | -z] [<key>...]\n\n      DESCRIPTION\n      -----------\n    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN\n      COMMANDS\n      --------\n     -`info [--format=(keyvalue|nul)] [<key>...]`::\n    -+`info [--format=(keyvalue|nul)|-z] [<key>...]`::\n    ++`info [--format=(keyvalue|nul) | -z] [<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).\n    @@ builtin/repo.c\n\n      static const char *const repo_usage[] = {\n     -\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n    -+\t\"git repo info [--format=(keyvalue|nul)|-z] [<key>...]\",\n    ++\t\"git repo info [--format=(keyvalue|nul) | -z] [<key>...]\",\n      \tNULL\n      };\n\n2:  37087dcc17 ! 2:  1d062e690e repo: add the field objects.format\n    @@ Documentation/git-repo.adoc: values that they return:\n      `layout.shallow`::\n      \t`true` if this is a shallow repository, otherwise `false`.\n\n    -+`objects.format`::\n    ++`object.format`::\n     +\tThe object format (hash algorithm) used in the repository.\n     +\n      `references.format`::\n    @@ builtin/repo.c: static int get_layout_shallow(struct repository *repo, struct st\n      \treturn 0;\n      }\n\n    -+static int get_objects_format(struct repository *repo, struct strbuf *buf)\n    ++static int get_object_format(struct repository *repo, struct strbuf *buf)\n     +{\n     +\tstrbuf_addstr(buf, repo->hash_algo->name);\n     +\treturn 0;\n    @@ builtin/repo.c: static int get_references_format(struct repository *repo, struct\n      static const struct field repo_info_fields[] = {\n      \t{ \"layout.bare\", get_layout_bare },\n      \t{ \"layout.shallow\", get_layout_shallow },\n    -+\t{ \"objects.format\", get_objects_format},\n    ++\t{ \"object.format\", get_object_format },\n      \t{ \"references.format\", get_references_format },\n      };\n\n    @@ t/t1900-repo.sh: test_expect_success 'setup remote' '\n      test_repo_info 'shallow repository = true is retrieved correctly' \\\n      \t'git clone --depth 1 \"file://$PWD/remote\"' 'shallow' 'layout.shallow' 'true'\n\n    -+test_repo_info 'objects.format = sha1 is retrieved correctly' \\\n    -+\t'git init --object-format=sha1' 'sha1' 'objects.format' 'sha1'\n    ++test_repo_info 'object.format = sha1 is retrieved correctly' \\\n    ++\t'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'\n     +\n    -+test_repo_info 'objects.format = sha256 is retrieved correctly' \\\n    -+\t'git init --object-format=sha256' 'sha256' 'objects.format' 'sha256'\n    ++test_repo_info 'object.format = sha256 is retrieved correctly' \\\n    ++\t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n     +\n      test_expect_success 'values returned in order requested' '\n      \tcat >expect <<-\\EOF &&\n\nLucas Seiki Oshiro (2):\n  repo: add the flag -z as an alias for --format=nul\n  repo: add the field objects.format\n\n Documentation/git-repo.adoc |  9 +++++++--\n builtin/repo.c              | 24 +++++++++++++++++++-----\n t/t1900-repo.sh             | 18 ++++++++++++++++++\n 3 files changed, 44 insertions(+), 7 deletions(-)\n\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"524988","messageId":"20250826183205.19566-2-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250826183205.19566-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v2 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-26T18:32:04Z","receivedAt":"2025-08-26T18:32:14Z","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 (e.g. git-config,\ngit-status, git-ls-files) have a flag `-z` for using the null character\nas the record separator.\n\nAdd the `-z` flag to git-repo-info as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc |  6 ++++--\n builtin/repo.c              | 17 ++++++++++++-----\n t/t1900-repo.sh             | 12 ++++++++++++\n 3 files changed, 28 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 2870828d93..8224a88bc8 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)] [<key>...]\n+git repo info [--format=(keyvalue|nul) | -z] [<key>...]\n \n DESCRIPTION\n -----------\n@@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [<key>...]`::\n+`info [--format=(keyvalue|nul) | -z] [<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).\n@@ -40,6 +40,8 @@ supported:\n \tbetween the key and the value and using a NUL character after each value.\n \tThis format is better suited for being parsed by another applications than\n \t`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.\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 8c6e7f42ab..5df33de42e 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -9,7 +9,7 @@\n #include \"shallow.h\"\n \n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul) | -z] [<key>...]\",\n \tNULL\n };\n \n@@ -115,20 +115,27 @@ static int print_fields(int argc, const char **argv,\n static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n-\tconst char *format_str = \"keyvalue\";\n+\tconst char *format_str = NULL;\n \tenum output_format format;\n+\tint format_nul = 0;\n \tstruct option options[] = {\n \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n \t\t\t   N_(\"output format\")),\n+\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n \t\tOPT_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n-\tif (!strcmp(format_str, \"keyvalue\"))\n-\t\tformat = FORMAT_KEYVALUE;\n-\telse if (!strcmp(format_str, \"nul\"))\n+\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n+\t\t\t\t  !!format_str, \"--format\");\n+\n+\tformat_str = format_str ? format_str : \"keyvalue\";\n+\n+\tif (format_nul || !strcmp(format_str, \"nul\"))\n \t\tformat = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(format_str, \"keyvalue\"))\n+\t\tformat = FORMAT_KEYVALUE;\n \telse\n \t\tdie(_(\"invalid format '%s'\"), format_str);\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex a69c715357..3df55dcc79 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -92,4 +92,16 @@ test_expect_success 'git-repo-info aborts when requesting an invalid format' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '-z uses nul-terminated format' '\n+\tprintf \"layout.bare\\nfalse\\0layout.shallow\\nfalse\\0\" >expected &&\n+\tgit repo info -z layout.bare layout.shallow >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git repo info fails when using --format and -z' '\n+\techo \"fatal: options ${SQ}-z${SQ} and ${SQ}--format${SQ} cannot be used together\" >expected &&\n+\ttest_must_fail git repo info -z --format=keyvalue 2>actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"524989","messageId":"20250826183205.19566-3-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250826183205.19566-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v2 2/2] repo: add the field objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-08-26T18:32:05Z","receivedAt":"2025-08-26T18:32:16Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"The flag `--show-object-format` from git-rev-parse is used for\nretrieving the object storage format. This way, it is used for\nquerying repository metadata, fitting in the purpose of git-repo-info.\n\nAdd a new field `objects.format` to the git-repo-info subcommand\ncontaining that information.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 3 +++\n builtin/repo.c              | 7 +++++++\n t/t1900-repo.sh             | 6 ++++++\n 3 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 8224a88bc8..2f9d696572 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -55,6 +55,9 @@ values that they return:\n `layout.shallow`::\n \t`true` if this is a shallow repository, otherwise `false`.\n \n+`object.format`::\n+\tThe object format (hash algorithm) used in the repository.\n+\n `references.format`::\n \tThe reference storage format. The valid values are:\n +\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 5df33de42e..5c900d683e 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -38,6 +38,12 @@ static int get_layout_shallow(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->hash_algo->name);\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf)\n {\n \tstrbuf_addstr(buf,\n@@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n static const struct field repo_info_fields[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n+\t{ \"object.format\", get_object_format },\n \t{ \"references.format\", get_references_format },\n };\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 3df55dcc79..a83139f7ff 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -63,6 +63,12 @@ test_expect_success 'setup remote' '\n test_repo_info 'shallow repository = true is retrieved correctly' \\\n \t'git clone --depth 1 \"file://$PWD/remote\"' 'shallow' 'layout.shallow' 'true'\n \n+test_repo_info 'object.format = sha1 is retrieved correctly' \\\n+\t'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'\n+\n+test_repo_info 'object.format = sha256 is retrieved correctly' \\\n+\t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525164","messageId":"xmqqcy8frqn2.fsf@gitster.g","threadId":"63995","inReplyTo":"20250826183205.19566-2-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH v2 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-28T23:08:17Z","receivedAt":"2025-08-28T23:08:20Z","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> Other Git commands that have nul-terminated output (e.g. git-config,\n> git-status, git-ls-files) have a flag `-z` for using the null character\n> as the record separator.\n\nPutting the devil's advocate hat on, \"--format=<plain,nul>\" was an\nattempt to avoid needless proliferation of options (e.g. presense of\n\"-z\" would tempt people into add \"--json\" when they introduce\n\"--format=json\"), so it may not be unconditionally a good idea to\nmimic these older commands where there are only two output formats.\n\nBut assuming that the short-and-sweet \"-z\" is something we want to\nadd, the patch itself looks pretty well done, but not quite.\n\n> Add the `-z` flag to git-repo-info as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 8c6e7f42ab..5df33de42e 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -115,20 +115,27 @@ static int print_fields(int argc, const char **argv,\n>  static int repo_info(int argc, const char **argv, const char *prefix,\n>  \t\t     struct repository *repo)\n>  {\n> -\tconst char *format_str = \"keyvalue\";\n> +\tconst char *format_str = NULL;\n>  \tenum output_format format;\n> +\tint format_nul = 0;\n>  \tstruct option options[] = {\n>  \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n>  \t\t\t   N_(\"output format\")),\n> +\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n>  \t\tOPT_END()\n>  \t};\n>  \n>  \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>  \n> -\tif (!strcmp(format_str, \"keyvalue\"))\n> -\t\tformat = FORMAT_KEYVALUE;\n> -\telse if (!strcmp(format_str, \"nul\"))\n\n\n> +\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n> +\t\t\t\t  !!format_str, \"--format\");\n\nHmph, so \"git repo info --format=nul -z\" is now forbidden?  That\ndoes not make much sense to me.\n\n> +\tformat_str = format_str ? format_str : \"keyvalue\";\n\n\tif (!format_str)\n\t\tformat_str = \"keyvalue\";\n\nis probably easier to follow, but I suspect this becomes a bit of\nmoot point as the general structure of this command line parsing may\nhave to change when you fix the \"-z is --format=nul so why are they\nincompatible?\" problem.\n\n> +\tif (format_nul || !strcmp(format_str, \"nul\"))\n>  \t\tformat = FORMAT_NUL_TERMINATED;\n> +\telse if (!strcmp(format_str, \"keyvalue\"))\n> +\t\tformat = FORMAT_KEYVALUE;\n>  \telse\n>  \t\tdie(_(\"invalid format '%s'\"), format_str);\n\nYou'd probably need to define a parseopt callback function for\n\"format\" and \"-z\", and remember the one that you saw the last.  So\ngiving \"-z --format=nul --format=text\" would first set an internal\n\"format\" to FORMAT_NUL_TERMINATED (due to \"-z\"), and then to the\nsame FORMAT_NUL_TERMINATED again (due to \"--format=nul\"), and then\nfinally to FORMAT_TEXT (due to \"--format=text\"), or something like\nthat, which would give the familiar \"the last one wins\" semantics.\n\nSomething like (not even compile tested):\n\n\tstatic int parse_format_cb(const struct option *opt,\n        \t\t\t   const char *arg, int unset)\n\t{\n\t\tenum otuput_format *format = opt->value;\n\n                if (opt->short_name == 'z')\n                \t*format = FORMAT_NUL_TERMINATED;\n\t\telse if (!strcmp(arg, \"nul\"))\n                \t*format = FORMAT_NUL_TERMINATED;\n\t\telse if (!strcmp(arg, \"keyvalue\"))\n                \t*format = FORMAT_KEYVALUE;\n\t\telse\n\t\t\tdie(_(\"invalid format '--format=%s'\", arg));\n\t\treturn 0;\n\t}\n\nwith\n\n\tenum output_format format = FORMAT_KEYVALUE;\n\tstruct option opt[] = {\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};\n\nperhaps?\n"},{"id":"525275","messageId":"FBD7B727-BE36-45FF-BD19-8086701C9753@gmail.com","threadId":"63995","inReplyTo":"xmqqcy8frqn2.fsf@gitster.g","subject":"Re: [GSoC PATCH v2 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-01T13:50:03Z","receivedAt":"2025-09-01T13:50:17Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> Putting the devil's advocate hat on, \"--format=<plain,nul>\" was an\n> attempt to avoid needless proliferation of options (e.g. presense of\n> \"-z\" would tempt people into add \"--json\" when they introduce\n> \"--format=json\"), so it may not be unconditionally a good idea to\n> mimic these older commands where there are only two output formats.\n\nYeah, I understand...\n\n> You'd probably need to define a parseopt callback function for\n> \"format\" and \"-z\", and remember the one that you saw the last.  So\n> giving \"-z --format=nul --format=text\" would first set an internal\n> \"format\" to FORMAT_NUL_TERMINATED (due to \"-z\"), and then to the\n> same FORMAT_NUL_TERMINATED again (due to \"--format=nul\"), and then\n> finally to FORMAT_TEXT (due to \"--format=text\"), or something like\n> that, which would give the familiar \"the last one wins\" semantics.\n\nOk, accepted! I'll also replace the tests and the documentation in\norder to match this behavior. Thanks!\n\n"},{"id":"525281","messageId":"20250901172732.98845-1-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v3 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-01T17:27:30Z","receivedAt":"2025-09-01T17:27:52Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThe major change in this v3 is that it's now possible to use --format and -z\ntogether. If the user uses a combination of two or more --format or -z, only\nthe last one will be considered.\n\nHere's the range-diff versus v2:\n\n1:  3ea40b1572 ! 1:  0323f1fa75 repo: add the flag -z as an alias for --format=nul\n    @@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor\n      --------\n      [synopsis]\n     -git repo info [--format=(keyvalue|nul)] [<key>...]\n    -+git repo info [--format=(keyvalue|nul) | -z] [<key>...]\n    ++git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n      \n      DESCRIPTION\n      -----------\n    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN\n      COMMANDS\n      --------\n     -`info [--format=(keyvalue|nul)] [<key>...]`::\n    -+`info [--format=(keyvalue|nul) | -z] [<key>...]`::\n    ++`info [--format=(keyvalue|nul)] [-z] [<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).\n    @@ builtin/repo.c\n      \n      static const char *const repo_usage[] = {\n     -\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n    -+\t\"git repo info [--format=(keyvalue|nul) | -z] [<key>...]\",\n    ++\t\"git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\",\n      \tNULL\n      };\n      \n     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n    + \treturn ret;\n    + }\n    + \n    ++static int parse_format_cb(const struct option *opt,\n    ++\t\t\t   const char *arg, int unset UNUSED) {\n    ++\tenum output_format *format = opt->value;\n    ++\n    ++\tif (opt->short_name == 'z')\n    ++\t\t*format = FORMAT_NUL_TERMINATED;\n    ++\telse if (!strcmp(arg, \"nul\"))\n    ++\t\t*format = FORMAT_NUL_TERMINATED;\n    ++\telse if (!strcmp(arg, \"keyvalue\"))\n    ++\t\t*format = FORMAT_KEYVALUE;\n    ++\telse\n    ++\t\tdie(_(\"invalid format '%s'\"), arg);\n    ++\n    ++\treturn 0;\n    ++}\n    ++\n      static int repo_info(int argc, const char **argv, const char *prefix,\n      \t\t     struct repository *repo)\n      {\n     -\tconst char *format_str = \"keyvalue\";\n    -+\tconst char *format_str = NULL;\n    - \tenum output_format format;\n    -+\tint format_nul = 0;\n    +-\tenum output_format format;\n    ++\tenum output_format format = FORMAT_KEYVALUE;\n      \tstruct option options[] = {\n    - \t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n    - \t\t\t   N_(\"output format\")),\n    -+\t\tOPT_BOOL('z', NULL, &format_nul, N_(\"alias for --format=nul\")),\n    +-\t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n    +-\t\t\t   N_(\"output format\")),\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_END()\n      \t};\n      \n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     -\tif (!strcmp(format_str, \"keyvalue\"))\n     -\t\tformat = FORMAT_KEYVALUE;\n     -\telse if (!strcmp(format_str, \"nul\"))\n    -+\tdie_for_incompatible_opt2(!!format_nul, \"-z\",\n    -+\t\t\t\t  !!format_str, \"--format\");\n    -+\n    -+\tformat_str = format_str ? format_str : \"keyvalue\";\n    -+\n    -+\tif (format_nul || !strcmp(format_str, \"nul\"))\n    - \t\tformat = FORMAT_NUL_TERMINATED;\n    -+\telse if (!strcmp(format_str, \"keyvalue\"))\n    -+\t\tformat = FORMAT_KEYVALUE;\n    - \telse\n    - \t\tdie(_(\"invalid format '%s'\"), format_str);\n    +-\t\tformat = FORMAT_NUL_TERMINATED;\n    +-\telse\n    +-\t\tdie(_(\"invalid format '%s'\"), format_str);\n    +-\n    + \treturn print_fields(argc, argv, repo, format);\n    + }\n      \n     \n      ## t/t1900-repo.sh ##\n    @@ t/t1900-repo.sh: test_expect_success 'git-repo-info aborts when requesting an in\n     +\ttest_cmp expected actual\n     +'\n     +\n    -+test_expect_success 'git repo info fails when using --format and -z' '\n    -+\techo \"fatal: options ${SQ}-z${SQ} and ${SQ}--format${SQ} cannot be used together\" >expected &&\n    -+\ttest_must_fail git repo info -z --format=keyvalue 2>actual &&\n    ++test_expect_success 'git repo info uses the last requested format' '\n    ++\techo \"layout.bare=false\" >expected &&\n    ++\tgit repo info --format=nul -z --format=keyvalue layout.bare >actual &&\n     +\ttest_cmp expected actual\n     +'\n     +\n2:  1d062e690e = 2:  b2b241f401 repo: add the field objects.format\n\n\nLucas Seiki Oshiro (2):\n  repo: add the flag -z as an alias for --format=nul\n  repo: add the field objects.format\n\n Documentation/git-repo.adoc |  9 ++++++--\n builtin/repo.c              | 44 +++++++++++++++++++++++++++----------\n t/t1900-repo.sh             | 18 +++++++++++++++\n 3 files changed, 57 insertions(+), 14 deletions(-)\n\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525282","messageId":"20250901172732.98845-2-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250901172732.98845-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v3 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-01T17:27:31Z","receivedAt":"2025-09-01T17:27:54Z","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 (e.g. git-config,\ngit-status, git-ls-files) have a flag `-z` for using the null character\nas the record separator.\n\nAdd the `-z` flag to git-repo-info as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc |  6 ++++--\n builtin/repo.c              | 37 +++++++++++++++++++++++++------------\n t/t1900-repo.sh             | 12 ++++++++++++\n 3 files changed, 41 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 2870828d93..6f5ee88215 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)] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n \n DESCRIPTION\n -----------\n@@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [<key>...]`::\n+`info [--format=(keyvalue|nul)] [-z] [<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).\n@@ -40,6 +40,8 @@ supported:\n \tbetween the key and the value and using a NUL character after each value.\n \tThis format is better suited for being parsed by another applications than\n \t`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.\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 8c6e7f42ab..13a34f68a5 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -9,7 +9,7 @@\n #include \"shallow.h\"\n \n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\",\n \tNULL\n };\n \n@@ -112,26 +112,39 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static int parse_format_cb(const struct option *opt,\n+\t\t\t   const char *arg, int unset UNUSED) {\n+\tenum output_format *format = opt->value;\n+\n+\tif (opt->short_name == 'z')\n+\t\t*format = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(arg, \"nul\"))\n+\t\t*format = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(arg, \"keyvalue\"))\n+\t\t*format = FORMAT_KEYVALUE;\n+\telse\n+\t\tdie(_(\"invalid format '%s'\"), arg);\n+\n+\treturn 0;\n+}\n+\n static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n-\tconst char *format_str = \"keyvalue\";\n-\tenum output_format format;\n+\tenum output_format format = FORMAT_KEYVALUE;\n \tstruct option options[] = {\n-\t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n-\t\t\t   N_(\"output format\")),\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_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n-\tif (!strcmp(format_str, \"keyvalue\"))\n-\t\tformat = FORMAT_KEYVALUE;\n-\telse if (!strcmp(format_str, \"nul\"))\n-\t\tformat = FORMAT_NUL_TERMINATED;\n-\telse\n-\t\tdie(_(\"invalid format '%s'\"), format_str);\n-\n \treturn print_fields(argc, argv, repo, format);\n }\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex a69c715357..ddf788d5a2 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -92,4 +92,16 @@ test_expect_success 'git-repo-info aborts when requesting an invalid format' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '-z uses nul-terminated format' '\n+\tprintf \"layout.bare\\nfalse\\0layout.shallow\\nfalse\\0\" >expected &&\n+\tgit repo info -z layout.bare layout.shallow >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git repo info uses the last requested format' '\n+\techo \"layout.bare=false\" >expected &&\n+\tgit repo info --format=nul -z --format=keyvalue layout.bare >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525283","messageId":"20250901172732.98845-3-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250901172732.98845-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v3 2/2] repo: add the field objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-01T17:27:32Z","receivedAt":"2025-09-01T17:27:56Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"The flag `--show-object-format` from git-rev-parse is used for\nretrieving the object storage format. This way, it is used for\nquerying repository metadata, fitting in the purpose of git-repo-info.\n\nAdd a new field `objects.format` to the git-repo-info subcommand\ncontaining that information.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 3 +++\n builtin/repo.c              | 7 +++++++\n t/t1900-repo.sh             | 6 ++++++\n 3 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 6f5ee88215..209afd1b61 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -55,6 +55,9 @@ values that they return:\n `layout.shallow`::\n \t`true` if this is a shallow repository, otherwise `false`.\n \n+`object.format`::\n+\tThe object format (hash algorithm) used in the repository.\n+\n `references.format`::\n \tThe reference storage format. The valid values are:\n +\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 13a34f68a5..9b519426fe 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -38,6 +38,12 @@ static int get_layout_shallow(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->hash_algo->name);\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf)\n {\n \tstrbuf_addstr(buf,\n@@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n static const struct field repo_info_fields[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n+\t{ \"object.format\", get_object_format },\n \t{ \"references.format\", get_references_format },\n };\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex ddf788d5a2..2beba67889 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -63,6 +63,12 @@ test_expect_success 'setup remote' '\n test_repo_info 'shallow repository = true is retrieved correctly' \\\n \t'git clone --depth 1 \"file://$PWD/remote\"' 'shallow' 'layout.shallow' 'true'\n \n+test_repo_info 'object.format = sha1 is retrieved correctly' \\\n+\t'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'\n+\n+test_repo_info 'object.format = sha256 is retrieved correctly' \\\n+\t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525347","messageId":"xmqqms7cltak.fsf@gitster.g","threadId":"63995","inReplyTo":"20250901172732.98845-2-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH v3 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-02T16:21:07Z","receivedAt":"2025-09-02T16:21:09Z","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> Other Git commands that have nul-terminated output (e.g. git-config,\n> git-status, git-ls-files) have a flag `-z` for using the null character\n> as the record separator.\n>\n> Add the `-z` flag to git-repo-info as an alias for `--format=nul`,\n> making it consistent with the behavior of the other commands.\n>\n> Mentored-by: Karthik Nayak <karthik.188@gmail.com>\n> Mentored-by: Patrick Steinhardt <ps@pks.im>\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n>  Documentation/git-repo.adoc |  6 ++++--\n>  builtin/repo.c              | 37 +++++++++++++++++++++++++------------\n>  t/t1900-repo.sh             | 12 ++++++++++++\n>  3 files changed, 41 insertions(+), 14 deletions(-)\n>\n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> index 2870828d93..6f5ee88215 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)] [<key>...]\n> +git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n\nThis is OK and I do not want you to reroll only to revert this, but\nFWIW what you had in the previous iteration\n\n    git repo info [--format=(keyvalue|nul) | -z] [<key>...]\n\nwould also work perfectly well here.  It is not like you are\nforbidding the command line to mention \"--format=nul\" twice, or\n\"--format=keyvalue --format=nul\" to allow the later one to override\nthe former ones.\n\nThe updated option parsing looks much nicer.  Thanks.\n"},{"id":"525379","messageId":"E6D61B04-E10A-4533-BB5F-E8E066AB4ADD@gmail.com","threadId":"63995","inReplyTo":"xmqqms7cltak.fsf@gitster.g","subject":"Re: [GSoC PATCH v3 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-02T21:51:43Z","receivedAt":"2025-09-02T21:51:59Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> This is OK and I do not want you to reroll only to revert this, but\n> FWIW what you had in the previous iteration\n> \n>    git repo info [--format=(keyvalue|nul) | -z] [<key>...]\n> \n> would also work perfectly well here.  It is not like you are\n> forbidding the command line to mention \"--format=nul\" twice, or\n> \"--format=keyvalue --format=nul\" to allow the later one to override\n> the former ones.\n\nHmmm, ok!\n\n> The updated option parsing looks much nicer.  Thanks.\n\nThanks, Junio!\n\n\n"},{"id":"525516","messageId":"20250904134017.47364-1-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250820144247.79197-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v4 0/2] repo: add -z and objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-04T13:40:15Z","receivedAt":"2025-09-04T14:22:20Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThis v4 fixes two codestyle issues:\n\n- Break line before opening a brace\n- Add spaces surrounding a `|`\n\nHere's the range-diff versus v3:\n\n1:  0323f1fa75 ! 1:  19c84e1a48 repo: add the flag -z as an alias for --format=nul\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n      }\n\n     +static int parse_format_cb(const struct option *opt,\n    -+                     const char *arg, int unset UNUSED) {\n    ++                     const char *arg, int unset UNUSED)\n    ++{\n     +  enum output_format *format = opt->value;\n     +\n     +  if (opt->short_name == 'z')\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     +                         PARSE_OPT_NONEG, parse_format_cb),\n     +          OPT_CALLBACK_F('z', NULL, &format, NULL,\n     +                         N_(\"synonym for --format=nul\"),\n    -+                         PARSE_OPT_NONEG|PARSE_OPT_NOARG,\n    ++                         PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n     +                         parse_format_cb),\n                OPT_END()\n        };\n2:  b2b241f401 = 2:  6258316d93 repo: add the field objects.format\n\nLucas Seiki Oshiro (2):\n  repo: add the flag -z as an alias for --format=nul\n  repo: add the field objects.format\n\n Documentation/git-repo.adoc |  9 ++++++--\n builtin/repo.c              | 45 +++++++++++++++++++++++++++----------\n t/t1900-repo.sh             | 18 +++++++++++++++\n 3 files changed, 58 insertions(+), 14 deletions(-)\n\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525517","messageId":"20250904134017.47364-2-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250904134017.47364-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v4 1/2] repo: add the flag -z as an alias for --format=nul","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-04T13:40:16Z","receivedAt":"2025-09-04T14:22:23Z","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 (e.g. git-config,\ngit-status, git-ls-files) have a flag `-z` for using the null character\nas the record separator.\n\nAdd the `-z` flag to git-repo-info as an alias for `--format=nul`,\nmaking it consistent with the behavior of the other commands.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc |  6 ++++--\n builtin/repo.c              | 38 +++++++++++++++++++++++++------------\n t/t1900-repo.sh             | 12 ++++++++++++\n 3 files changed, 42 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 2870828d93..6f5ee88215 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)] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n \n DESCRIPTION\n -----------\n@@ -18,7 +18,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [<key>...]`::\n+`info [--format=(keyvalue|nul)] [-z] [<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).\n@@ -40,6 +40,8 @@ supported:\n \tbetween the key and the value and using a NUL character after each value.\n \tThis format is better suited for being parsed by another applications than\n \t`keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.\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 8c6e7f42ab..dc9a267469 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -9,7 +9,7 @@\n #include \"shallow.h\"\n \n static const char *const repo_usage[] = {\n-\t\"git repo info [--format=(keyvalue|nul)] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\",\n \tNULL\n };\n \n@@ -112,26 +112,40 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static int parse_format_cb(const struct option *opt,\n+\t\t\t   const char *arg, int unset UNUSED)\n+{\n+\tenum output_format *format = opt->value;\n+\n+\tif (opt->short_name == 'z')\n+\t\t*format = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(arg, \"nul\"))\n+\t\t*format = FORMAT_NUL_TERMINATED;\n+\telse if (!strcmp(arg, \"keyvalue\"))\n+\t\t*format = FORMAT_KEYVALUE;\n+\telse\n+\t\tdie(_(\"invalid format '%s'\"), arg);\n+\n+\treturn 0;\n+}\n+\n static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n-\tconst char *format_str = \"keyvalue\";\n-\tenum output_format format;\n+\tenum output_format format = FORMAT_KEYVALUE;\n \tstruct option options[] = {\n-\t\tOPT_STRING(0, \"format\", &format_str, N_(\"format\"),\n-\t\t\t   N_(\"output format\")),\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_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n-\tif (!strcmp(format_str, \"keyvalue\"))\n-\t\tformat = FORMAT_KEYVALUE;\n-\telse if (!strcmp(format_str, \"nul\"))\n-\t\tformat = FORMAT_NUL_TERMINATED;\n-\telse\n-\t\tdie(_(\"invalid format '%s'\"), format_str);\n-\n \treturn print_fields(argc, argv, repo, format);\n }\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex a69c715357..ddf788d5a2 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -92,4 +92,16 @@ test_expect_success 'git-repo-info aborts when requesting an invalid format' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success '-z uses nul-terminated format' '\n+\tprintf \"layout.bare\\nfalse\\0layout.shallow\\nfalse\\0\" >expected &&\n+\tgit repo info -z layout.bare layout.shallow >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git repo info uses the last requested format' '\n+\techo \"layout.bare=false\" >expected &&\n+\tgit repo info --format=nul -z --format=keyvalue layout.bare >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525518","messageId":"20250904134017.47364-3-lucasseikioshiro@gmail.com","threadId":"63995","inReplyTo":"20250904134017.47364-1-lucasseikioshiro@gmail.com","subject":"[GSoC PATCH v4 2/2] repo: add the field objects.format","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-04T13:40:17Z","receivedAt":"2025-09-04T14:22:25Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"The flag `--show-object-format` from git-rev-parse is used for\nretrieving the object storage format. This way, it is used for\nquerying repository metadata, fitting in the purpose of git-repo-info.\n\nAdd a new field `objects.format` to the git-repo-info subcommand\ncontaining that information.\n\nMentored-by: Karthik Nayak <karthik.188@gmail.com>\nMentored-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n Documentation/git-repo.adoc | 3 +++\n builtin/repo.c              | 7 +++++++\n t/t1900-repo.sh             | 6 ++++++\n 3 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 6f5ee88215..209afd1b61 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -55,6 +55,9 @@ values that they return:\n `layout.shallow`::\n \t`true` if this is a shallow repository, otherwise `false`.\n \n+`object.format`::\n+\tThe object format (hash algorithm) used in the repository.\n+\n `references.format`::\n \tThe reference storage format. The valid values are:\n +\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex dc9a267469..bbb0966f2d 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -38,6 +38,12 @@ static int get_layout_shallow(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_object_format(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo->hash_algo->name);\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf)\n {\n \tstrbuf_addstr(buf,\n@@ -49,6 +55,7 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n static const struct field repo_info_fields[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n+\t{ \"object.format\", get_object_format },\n \t{ \"references.format\", get_references_format },\n };\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex ddf788d5a2..2beba67889 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -63,6 +63,12 @@ test_expect_success 'setup remote' '\n test_repo_info 'shallow repository = true is retrieved correctly' \\\n \t'git clone --depth 1 \"file://$PWD/remote\"' 'shallow' 'layout.shallow' 'true'\n \n+test_repo_info 'object.format = sha1 is retrieved correctly' \\\n+\t'git init --object-format=sha1' 'sha1' 'object.format' 'sha1'\n+\n+test_repo_info 'object.format = sha256 is retrieved correctly' \\\n+\t'git init --object-format=sha256' 'sha256' 'object.format' 'sha256'\n+\n test_expect_success 'values returned in order requested' '\n \tcat >expect <<-\\EOF &&\n \tlayout.bare=false\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"525558","messageId":"xmqq5xdy83jx.fsf@gitster.g","threadId":"63995","inReplyTo":"20250904134017.47364-1-lucasseikioshiro@gmail.com","subject":"Re: [GSoC PATCH v4 0/2] repo: add -z and objects.format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-04T18:40:02Z","receivedAt":"2025-09-04T18:40:05Z","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> This v4 fixes two codestyle issues:\n>\n> - Break line before opening a brace\n> - Add spaces surrounding a `|`\n\nLooks good.  THese are the only things\n\n    $ git clang-format --diff HEAD~2 HEAD\n\nreports on the version that has been in my tree.\n\nWill queue; let's mark it for 'next'.\n\n>\n> Here's the range-diff versus v3:\n>\n> 1:  0323f1fa75 ! 1:  19c84e1a48 repo: add the flag -z as an alias for --format=nul\n>     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n>       }\n>\n>      +static int parse_format_cb(const struct option *opt,\n>     -+                     const char *arg, int unset UNUSED) {\n>     ++                     const char *arg, int unset UNUSED)\n>     ++{\n>      +  enum output_format *format = opt->value;\n>      +\n>      +  if (opt->short_name == 'z')\n>     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n>      +                         PARSE_OPT_NONEG, parse_format_cb),\n>      +          OPT_CALLBACK_F('z', NULL, &format, NULL,\n>      +                         N_(\"synonym for --format=nul\"),\n>     -+                         PARSE_OPT_NONEG|PARSE_OPT_NOARG,\n>     ++                         PARSE_OPT_NONEG | PARSE_OPT_NOARG,\n>      +                         parse_format_cb),\n>                 OPT_END()\n>         };\n> 2:  b2b241f401 = 2:  6258316d93 repo: add the field objects.format\n>\n> Lucas Seiki Oshiro (2):\n>   repo: add the flag -z as an alias for --format=nul\n>   repo: add the field objects.format\n>\n>  Documentation/git-repo.adoc |  9 ++++++--\n>  builtin/repo.c              | 45 +++++++++++++++++++++++++++----------\n>  t/t1900-repo.sh             | 18 +++++++++++++++\n>  3 files changed, 58 insertions(+), 14 deletions(-)\n"}]}