{"thread":{"id":"64151","subject":"[PATCH] repo: add --all to git-repo-info","startedAt":"2025-09-15T22:36:35Z","lastAt":"2025-11-20T22:50:24Z","messageCount":30,"participants":["Lucas Seiki Oshiro","Junio C Hamano","Patrick Steinhardt","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"526400","messageId":"20250915223618.13093-1-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":null,"subject":"[PATCH] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-09-15T22:36:17Z","receivedAt":"2025-09-15T22:36:35Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Add a new flag `--all` to git-repo-info for requesting all the available\nkeys. By using this flag, the user can retrieve all the values instead\nof searching what are the desired keys for what they wants.\n\nHelped-by: Karthik Nayak <karthik.188@gmail.com>\nHelped-by: Patrick Steinhardt <ps@pks.im>\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\nHi!\n\nThis patch is an epilogue of my GSoC, as it was requested to have some\nway to retrieve all the values without needing to pass all the keys.\n\nThis is built on top of the current master, a483264b01 (The ninth\nbatch, 2025-09-15).\n\n Documentation/git-repo.adoc |  6 ++--\n builtin/repo.c              | 62 ++++++++++++++++++++++++++++---------\n t/t1900-repo.sh             |  6 ++++\n 3 files changed, 56 insertions(+), 18 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 209afd1b61..2caf093a9a 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] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [--all] [<key>...]\n \n DESCRIPTION\n -----------\n@@ -18,13 +18,13 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [-z] [<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).\n +\n The values are returned in the same order in which their respective keys were\n-requested.\n+requested. The `--all` flag requests all keys.\n +\n The output format can be chosen through the flag `--format`. Two formats are\n supported:\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex bbb0966f2d..906d8a3e12 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)] [-z] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul)] [-z] [--all] [<key>...]\",\n \tNULL\n };\n \n@@ -77,6 +77,24 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n \treturn found ? found->get_value : NULL;\n }\n \n+static void print_field(enum output_format format, const char *key,\n+\t\t\tstruct strbuf *valbuf, struct strbuf *quotbuf)\n+{\n+\tstrbuf_reset(quotbuf);\n+\n+\tswitch (format) {\n+\tcase FORMAT_KEYVALUE:\n+\t\tquote_c_style(valbuf->buf, quotbuf, NULL, 0);\n+\t\tprintf(\"%s=%s\\n\", key, quotbuf->buf);\n+\t\tbreak;\n+\tcase FORMAT_NUL_TERMINATED:\n+\t\tprintf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"not a valid output format: %d\", format);\n+\t}\n+}\n+\n static int print_fields(int argc, const char **argv,\n \t\t\tstruct repository *repo,\n \t\t\tenum output_format format)\n@@ -97,21 +115,8 @@ static int print_fields(int argc, const char **argv,\n \t\t}\n \n \t\tstrbuf_reset(&valbuf);\n-\t\tstrbuf_reset(&quotbuf);\n-\n \t\tget_value(repo, &valbuf);\n-\n-\t\tswitch (format) {\n-\t\tcase FORMAT_KEYVALUE:\n-\t\t\tquote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n-\t\t\tprintf(\"%s=%s\\n\", key, quotbuf.buf);\n-\t\t\tbreak;\n-\t\tcase FORMAT_NUL_TERMINATED:\n-\t\t\tprintf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tBUG(\"not a valid output format: %d\", format);\n-\t\t}\n+\t\tprint_field(format, key, &valbuf, &quotbuf);\n \t}\n \n \tstrbuf_release(&valbuf);\n@@ -119,6 +124,26 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static void print_all_fields(struct repository *repo,\n+\t\t\t     enum output_format format)\n+{\n+\tstruct strbuf valbuf = STRBUF_INIT;\n+\tstruct strbuf quotbuf = STRBUF_INIT;\n+\n+\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n+\t\tstruct field field = repo_info_fields[i];\n+\t\tget_value_fn *get_value = field.get_value;\n+\t\tconst char *key = field.key;\n+\n+\t\tstrbuf_reset(&valbuf);\n+\t\tget_value(repo, &valbuf);\n+\t\tprint_field(format, key, &valbuf, &quotbuf);\n+\t}\n+\n+\tstrbuf_release(&valbuf);\n+\tstrbuf_release(&quotbuf);\n+}\n+\n static int parse_format_cb(const struct option *opt,\n \t\t\t   const char *arg, int unset UNUSED)\n {\n@@ -140,6 +165,7 @@ static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n \tenum output_format format = FORMAT_KEYVALUE;\n+\tint all_keys = 0;\n \tstruct option options[] = {\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n@@ -148,11 +174,17 @@ static int repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"return all keys\")),\n \t\tOPT_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n+\tif (all_keys) {\n+\t\tprint_all_fields(repo, format);\n+\t\treturn 0;\n+\t}\n+\n \treturn print_fields(argc, argv, repo, format);\n }\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 2beba67889..b1391a47b6 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -110,4 +110,10 @@ test_expect_success 'git repo info uses the last requested format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'git repo info --all returns all fields' '\n+\tgit repo info layout.bare layout.shallow object.format references.format >expect &&\n+\tgit repo info --all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.39.5 (Apple Git-154)\n\n"},{"id":"526405","messageId":"xmqqfrcnclp3.fsf@gitster.g","threadId":"64151","inReplyTo":"20250915223618.13093-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-15T23:58:32Z","receivedAt":"2025-09-15T23:58:35Z","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> Add a new flag `--all` to git-repo-info for requesting all the available\n> keys. By using this flag, the user can retrieve all the values instead\n> of searching what are the desired keys for what they wants.\n\nI initially read these three lines as \"we let you grab all the keys\n(without value), so that the caller do it once and then iterate over\nthem, asking for the values individually\".\n\nI think \"for requesting all the available keys\" can be tweaked to\navoid such a misunderstanding?\n\n    for requesting values for all the available keys\n\nor something, perhaps?\n\n> -git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n> +git repo info [--format=(keyvalue|nul)] [-z] [--all] [<key>...]\n\nWouldn't it be more like\n\n\t..... [--all | <key>...]\n\nor does giving both --all and an indiviual key do something\ninteresting (like, just make sure these individual keys are valid,\nbut otherwise do the same as a simple --all)?\n\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).\n>  +\n>  The values are returned in the same order in which their respective keys were\n> -requested.\n> +requested. The `--all` flag requests all keys.\n\n\"requests values for all the keys.\"\n\n>  \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>  \n> +\tif (all_keys) {\n> +\t\tprint_all_fields(repo, format);\n> +\t\treturn 0;\n> +\t}\n> +\n>  \treturn print_fields(argc, argv, repo, format);\n\nOK, so \"git repo info --all no-such-key\" will silently ignore\nno-such-key.  I do not have much problem as long as it is\ndocumented, but there are a few equally plausible alternative\ndesigns.\n\n * \"git repo info --all anything\" ignores \"anything\" no matter what\n   they are, as \"--all\" makes all keys on the command line ignored.\n\n * The same as above, but it warns about the extra command line\n   arguments that are ignored.\n\n * \"git repo info --all object.format\" is rejected merely because\n   \"--all\" is defined to be incompatible with giving any individual\n   key.\n\n * \"git repo info --all object.format\" works as if the command is\n   given all the defined keys and then object.format, i.e.\n   object.format is reported twice.  If you ask \"git repo info\n   --all no.such.key\", it would fail while asking for no.such.key\n   because there is no such key.\n\nI think the first one is what you have implemented.\n\nI see no practical reason why anybody want to pass a concrete key\nwhen asking \"--all\", but the first one feels the least intuitive one\namong these four.  I think the last one is the most logical that\nlets users discover why it behaves that way the most easily, even\nthough it is debatable that succeeding and doing exactly what was\nrequested in that way is better than rejecting (or perhaps ignoring\nwith warning) these requests with extra command line arguments.\n\n> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\n> index 2beba67889..b1391a47b6 100755\n> --- a/t/t1900-repo.sh\n> +++ b/t/t1900-repo.sh\n> @@ -110,4 +110,10 @@ test_expect_success 'git repo info uses the last requested format' '\n>  \ttest_cmp expected actual\n>  '\n>  \n> +test_expect_success 'git repo info --all returns all fields' '\n> +\tgit repo info layout.bare layout.shallow object.format references.format >expect &&\n> +\tgit repo info --all >actual &&\n> +\ttest_cmp expect actual\n\nWe would want tests that asks \"--all object.format\" and \"--all no.key\",\nafter deciding what should happen.\n\nThanks.\n"},{"id":"526429","messageId":"aMkaePi90Q6sXuO4@pks.im","threadId":"64151","inReplyTo":"20250915223618.13093-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH] repo: add --all to git-repo-info","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-09-16T08:06:16Z","receivedAt":"2025-09-16T08:06:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Sep 15, 2025 at 07:36:17PM -0300, Lucas Seiki Oshiro wrote:\n> Add a new flag `--all` to git-repo-info for requesting all the available\n> keys. By using this flag, the user can retrieve all the values instead\n> of searching what are the desired keys for what they wants.\n\nOne thing I wonder is whether we actually need the \"--all\" flag in the\nfirst place. Right now, when saying `git repo info` without any further\narguments, then the user will be met with complete silence. I don't\nreally think that this is useful as a default in any way, as it makes it\nvery difficult for the user to figure out what kind of information\nexists in the first place.\n\nSo how about we don't introduce a separate flag, but instead detect the\ncase where the user passed no arguments at all and then print all values\nby default? It changes the current behaviour, but on the other hand I\nwould argue that the current behaviour is not useful in the first place.\nAnd the command is labelled as experimental anyway, so for now we still\ncan change it.\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index bbb0966f2d..906d8a3e12 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -77,6 +77,24 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n>  \treturn found ? found->get_value : NULL;\n>  }\n>  \n> +static void print_field(enum output_format format, const char *key,\n> +\t\t\tstruct strbuf *valbuf, struct strbuf *quotbuf)\n> +{\n> +\tstrbuf_reset(quotbuf);\n> +\n> +\tswitch (format) {\n> +\tcase FORMAT_KEYVALUE:\n> +\t\tquote_c_style(valbuf->buf, quotbuf, NULL, 0);\n> +\t\tprintf(\"%s=%s\\n\", key, quotbuf->buf);\n> +\t\tbreak;\n> +\tcase FORMAT_NUL_TERMINATED:\n> +\t\tprintf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tBUG(\"not a valid output format: %d\", format);\n> +\t}\n> +}\n> +\n>  static int print_fields(int argc, const char **argv,\n>  \t\t\tstruct repository *repo,\n>  \t\t\tenum output_format format)\n\nChanges like this which are preparatory refactorings can also be split\nout into separate commits. That makes it easier to see and review such a\nchange standalone.\n\n> @@ -119,6 +124,26 @@ static int print_fields(int argc, const char **argv,\n>  \treturn ret;\n>  }\n>  \n> +static void print_all_fields(struct repository *repo,\n> +\t\t\t     enum output_format format)\n> +{\n> +\tstruct strbuf valbuf = STRBUF_INIT;\n> +\tstruct strbuf quotbuf = STRBUF_INIT;\n> +\n> +\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n> +\t\tstruct field field = repo_info_fields[i];\n> +\t\tget_value_fn *get_value = field.get_value;\n> +\t\tconst char *key = field.key;\n\nNit: I don't really feel like the `get_value` or `key` variables help\nmuch. I'd just drop those.\n\n> @@ -140,6 +165,7 @@ static int repo_info(int argc, const char **argv, const char *prefix,\n>  \t\t     struct repository *repo)\n>  {\n>  \tenum output_format format = FORMAT_KEYVALUE;\n> +\tint all_keys = 0;\n>  \tstruct option options[] = {\n>  \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n>  \t\t\t       N_(\"output format\"),\n> @@ -148,11 +174,17 @@ static int repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"return all keys\")),\n>  \t\tOPT_END()\n>  \t};\n>  \n>  \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>  \n> +\tif (all_keys) {\n> +\t\tprint_all_fields(repo, format);\n> +\t\treturn 0;\n> +\t}\n\nInstead of checking for `all_keys` we could check for `if (!argc)` if\nyou want to follow my suggestion.\n\n>  \treturn print_fields(argc, argv, repo, format);\n>  }\n>  \n> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\n> index 2beba67889..b1391a47b6 100755\n> --- a/t/t1900-repo.sh\n> +++ b/t/t1900-repo.sh\n> @@ -110,4 +110,10 @@ test_expect_success 'git repo info uses the last requested format' '\n>  \ttest_cmp expected actual\n>  '\n>  \n> +test_expect_success 'git repo info --all returns all fields' '\n> +\tgit repo info layout.bare layout.shallow object.format references.format >expect &&\n> +\tgit repo info --all >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nThis test will obviously need to be adapted every time we add a new\nfield, which I think is fine. But we should adapt it so that it's easily\nextensible without by just adding another line. E.g. like this:\n\n    test_expect_success 'git repo info --all returns all fields' '\n            git repo info \\\n                layout.bare \\\n                layout.shallow \\\n                object.format \\\n                references.format \\\n                >expect &&\n            git repo info --all >actual &&\n            test_cmp expect actual\n    '\n\nThis ensures that it's as simple as adding a new line when we add a\nspecific field without having to rewrite the whole line.\n\nPatrick\n"},{"id":"526452","messageId":"xmqqv7linzex.fsf@gitster.g","threadId":"64151","inReplyTo":"aMkaePi90Q6sXuO4@pks.im","subject":"Re: [PATCH] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-16T16:19:02Z","receivedAt":"2025-09-16T16:19:05Z","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> One thing I wonder is whether we actually need the \"--all\" flag in the\n> first place. Right now, when saying `git repo info` without any further\n> arguments, then the user will be met with complete silence. I don't\n> really think that this is useful as a default in any way, as it makes it\n> very difficult for the user to figure out what kind of information\n> exists in the first place.\n\nIf we were talking about interactive tool, I might agree, but for a\ntool for scriptors,\n\n    tool \"$@\"\n\nshould not silently turn into\n\n    tool --all\n\nwhen $# == 0.  That is asking for surprises.\n\n"},{"id":"526539","messageId":"aMpIaVPdgnbhBvlG@pks.im","threadId":"64151","inReplyTo":"xmqqv7linzex.fsf@gitster.g","subject":"Re: [PATCH] repo: add --all to git-repo-info","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-09-17T05:34:33Z","receivedAt":"2025-09-17T05:34:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Sep 16, 2025 at 09:19:02AM -0700, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > One thing I wonder is whether we actually need the \"--all\" flag in the\n> > first place. Right now, when saying `git repo info` without any further\n> > arguments, then the user will be met with complete silence. I don't\n> > really think that this is useful as a default in any way, as it makes it\n> > very difficult for the user to figure out what kind of information\n> > exists in the first place.\n> \n> If we were talking about interactive tool, I might agree, but for a\n> tool for scriptors,\n> \n>     tool \"$@\"\n> \n> should not silently turn into\n> \n>     tool --all\n> \n> when $# == 0.  That is asking for surprises.\n\nThat's fair. Let's stick with a flag then.\n\nPatrick\n"},{"id":"529664","messageId":"20251026225409.46647-1-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20250915223618.13093-1-lucasseikioshiro@gmail.com","subject":"[PATCH v3 0/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-10-26T22:52:06Z","receivedAt":"2025-10-26T22:54:27Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThis is the third version of the patchset that adds a new flag --all\nto git-repo-info for requesting the values of all the available flags.\n\nNow, in this version, git-repo-info will abort if it is called with --all\nand some key.\n\nHere's the range-diff against v2:\n\n1:  5f72f07589 = 1:  0db9aad2bc repo: factor out field printing to dedicated function\n2:  b8158bb7b8 ! 2:  b6ecdc2c2f repo: add --all to git-repo-info\n    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN\n      The values are returned in the same order in which their respective keys were\n     -requested.\n     +requested. The `--all` flag requests the values for all the available keys.\n    -+Keys requested after `--all` will be duplicated.\n      +\n      The output format can be chosen through the flag `--format`. Two formats are\n      supported:\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     +\n     +\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n     +\t\tstruct field field = repo_info_fields[i];\n    -+\t\tget_value_fn *get_value = field.get_value;\n    -+\t\tconst char *key = field.key;\n     +\n     +\t\tstrbuf_reset(&valbuf);\n    -+\t\tget_value(repo, &valbuf);\n    -+\t\tprint_field(format, key, &valbuf, &quotbuf);\n    ++\t\tfield.get_value(repo, &valbuf);\n    ++\t\tprint_field(format, field.key, &valbuf, &quotbuf);\n     +\t}\n     +\n     +\tstrbuf_release(&valbuf);\n    @@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *pr\n      \n      \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n      \n    -+\tif (all_keys)\n    ++\tif (all_keys) {\n    ++\t\tif (argc)\n    ++\t\t\tdie(_(\"--all and <key> cannot be used together\"));\n    ++\n     +\t\tprint_all_fields(repo, format);\n    ++\t\treturn 0;\n    ++\t}\n     +\n      \treturn print_fields(argc, argv, repo, format);\n      }\n    @@ t/t1900-repo.sh: test_expect_success 'git repo info uses the last requested form\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'git repo info --all <key> duplicates <key>' '\n    -+\tgit repo info $REPO_INFO_KEYS object.format >expect &&\n    -+\tgit repo info --all object.format >actual &&\n    ++test_expect_success 'git repo info --all <key> aborts' '\n    ++\techo \"fatal: --all and <key> cannot be used together\" >expect &&\n    ++\ttest_must_fail git repo info --all object.format 2>actual &&\n     +\ttest_cmp expect actual\n     +'\n    -+\n    -+test_expect_success 'git repo info --all <invalid key> warns about invalid key' '\n    -+\tgit repo info $REPO_INFO_KEYS >expect &&\n    -+\techo \"error: key ${SQ}no.key${SQ} not found\" >expect_err &&\n    -+\ttest_must_fail git repo info --all no.key >actual 2>actual_err &&\n    -+\ttest_cmp expect actual &&\n    -+\ttest_cmp expect_err actual_err\n    -+'\n     +\n      test_done\n\nLucas Seiki Oshiro (2):\n  repo: factor out field printing to dedicated function\n  repo: add --all to git-repo-info\n\n Documentation/git-repo.adoc |  6 ++--\n builtin/repo.c              | 63 ++++++++++++++++++++++++++++---------\n t/t1900-repo.sh             | 21 +++++++++++++\n 3 files changed, 72 insertions(+), 18 deletions(-)\n\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"529665","messageId":"20251026225409.46647-2-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251026225409.46647-1-lucasseikioshiro@gmail.com","subject":"[PATCH v3 1/2] repo: factor out field printing to dedicated function","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-10-26T22:52:07Z","receivedAt":"2025-10-26T22:54:29Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Move the field printing in git-repo-info to a new function called\n`print_field`, allowing it to be called by functions other than\n`print_fields`.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n builtin/repo.c | 33 +++++++++++++++++++--------------\n 1 file changed, 19 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex bbb0966f2d..3b071e9a50 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -77,6 +77,24 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n \treturn found ? found->get_value : NULL;\n }\n \n+static void print_field(enum output_format format, const char *key,\n+\t\t\tstruct strbuf *valbuf, struct strbuf *quotbuf)\n+{\n+\tstrbuf_reset(quotbuf);\n+\n+\tswitch (format) {\n+\tcase FORMAT_KEYVALUE:\n+\t\tquote_c_style(valbuf->buf, quotbuf, NULL, 0);\n+\t\tprintf(\"%s=%s\\n\", key, quotbuf->buf);\n+\t\tbreak;\n+\tcase FORMAT_NUL_TERMINATED:\n+\t\tprintf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"not a valid output format: %d\", format);\n+\t}\n+}\n+\n static int print_fields(int argc, const char **argv,\n \t\t\tstruct repository *repo,\n \t\t\tenum output_format format)\n@@ -97,21 +115,8 @@ static int print_fields(int argc, const char **argv,\n \t\t}\n \n \t\tstrbuf_reset(&valbuf);\n-\t\tstrbuf_reset(&quotbuf);\n-\n \t\tget_value(repo, &valbuf);\n-\n-\t\tswitch (format) {\n-\t\tcase FORMAT_KEYVALUE:\n-\t\t\tquote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n-\t\t\tprintf(\"%s=%s\\n\", key, quotbuf.buf);\n-\t\t\tbreak;\n-\t\tcase FORMAT_NUL_TERMINATED:\n-\t\t\tprintf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tBUG(\"not a valid output format: %d\", format);\n-\t\t}\n+\t\tprint_field(format, key, &valbuf, &quotbuf);\n \t}\n \n \tstrbuf_release(&valbuf);\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"529666","messageId":"20251026225409.46647-3-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251026225409.46647-1-lucasseikioshiro@gmail.com","subject":"[PATCH v3 2/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-10-26T22:52:08Z","receivedAt":"2025-10-26T22:54:32Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Add a new flag `--all` to git-repo-info for requesting values for all\nthe available keys. By using this flag, the user can retrieve all the\nvalues instead of searching what are the desired keys for what they\nwants.\n\nHelped-by: Karthik Nayak <karthik.188@gmail.com>\nHelped-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              | 30 +++++++++++++++++++++++++++++-\n t/t1900-repo.sh             | 21 +++++++++++++++++++++\n 3 files changed, 53 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 209afd1b61..e61af9ce3b 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] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n \n DESCRIPTION\n -----------\n@@ -18,13 +18,13 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [-z] [<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).\n +\n The values are returned in the same order in which their respective keys were\n-requested.\n+requested. The `--all` flag requests the values for all the available keys.\n +\n The output format can be chosen through the flag `--format`. Two formats are\n supported:\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 3b071e9a50..67d647bb3c 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)] [-z] [<key>...]\",\n+\t\"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\",\n \tNULL\n };\n \n@@ -124,6 +124,24 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static void print_all_fields(struct repository *repo,\n+\t\t\t     enum output_format format)\n+{\n+\tstruct strbuf valbuf = STRBUF_INIT;\n+\tstruct strbuf quotbuf = STRBUF_INIT;\n+\n+\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n+\t\tstruct field field = repo_info_fields[i];\n+\n+\t\tstrbuf_reset(&valbuf);\n+\t\tfield.get_value(repo, &valbuf);\n+\t\tprint_field(format, field.key, &valbuf, &quotbuf);\n+\t}\n+\n+\tstrbuf_release(&valbuf);\n+\tstrbuf_release(&quotbuf);\n+}\n+\n static int parse_format_cb(const struct option *opt,\n \t\t\t   const char *arg, int unset UNUSED)\n {\n@@ -145,6 +163,7 @@ static int repo_info(int argc, const char **argv, const char *prefix,\n \t\t     struct repository *repo)\n {\n \tenum output_format format = FORMAT_KEYVALUE;\n+\tint all_keys = 0;\n \tstruct option options[] = {\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n@@ -153,11 +172,20 @@ static int repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"return all keys\")),\n \t\tOPT_END()\n \t};\n \n \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n \n+\tif (all_keys) {\n+\t\tif (argc)\n+\t\t\tdie(_(\"--all and <key> cannot be used together\"));\n+\n+\t\tprint_all_fields(repo, format);\n+\t\treturn 0;\n+\t}\n+\n \treturn print_fields(argc, argv, repo, format);\n }\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 2beba67889..51d55f11a5 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -4,6 +4,15 @@ test_description='test git repo-info'\n \n . ./test-lib.sh\n \n+# git-repo-info keys. It must contain the same keys listed in the const\n+# repo_info_fields, in lexicographical order.\n+REPO_INFO_KEYS='\n+\tlayout.bare\n+\tlayout.shallow\n+\tobject.format\n+\treferences.format\n+'\n+\n # Test whether a key-value pair is correctly returned\n #\n # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>\n@@ -110,4 +119,16 @@ test_expect_success 'git repo info uses the last requested format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'git repo info --all returns all key-value pairs' '\n+\tgit repo info $REPO_INFO_KEYS >expect &&\n+\tgit repo info --all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git repo info --all <key> aborts' '\n+\techo \"fatal: --all and <key> cannot be used together\" >expect &&\n+\ttest_must_fail git repo info --all object.format 2>actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"529668","messageId":"CAPig+cQO4_T8K-8wFBDQN-n+rasBF7LR+vJ6ez8swfmDz1ossg@mail.gmail.com","threadId":"64151","inReplyTo":"20251026225409.46647-2-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v3 1/2] repo: factor out field printing to dedicated function","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-26T23:53:38Z","receivedAt":"2025-10-26T23:53:50Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Oct 26, 2025 at 6:54 PM Lucas Seiki Oshiro\n<lucasseikioshiro@gmail.com> wrote:\n> Move the field printing in git-repo-info to a new function called\n> `print_field`, allowing it to be called by functions other than\n> `print_fields`.\n>\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> @@ -77,6 +77,24 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n> +static void print_field(enum output_format format, const char *key,\n> +                       struct strbuf *valbuf, struct strbuf *quotbuf)\n> +{\n\nLet's not pass in 'valbuf' as a 'struct strbuf *' since doing so gives\nthe false impression that this function will be modifying the strbuf\n(which it does not do). Instead, pass in the narrower `const char\n*value` which indicates clearly that this function will not be\nmodifying the value.\n\n> +       strbuf_reset(quotbuf);\n> +\n> +       switch (format) {\n> +       case FORMAT_KEYVALUE:\n> +               quote_c_style(valbuf->buf, quotbuf, NULL, 0);\n> +               printf(\"%s=%s\\n\", key, quotbuf->buf);\n> +               break;\n> +       case FORMAT_NUL_TERMINATED:\n> +               printf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n> +               break;\n> +       default:\n> +               BUG(\"not a valid output format: %d\", format);\n> +       }\n> +}\n\nMoreover, I'd also say that since this is not on a critical path, you\nshould avoid the premature optimization of passing in `strfbuf\n*quotebuf` and instead make `quotebuf` local to this function.\n\n    static void print_field(enum output_format format,\n        const char *key, const char *value)\n    {\n        struct strbuf quotbuf = STRBUF_INIT;\n        ...stuff...\n        strbuf_release(&quotbuf);\n    }\n\n>  static int print_fields(int argc, const char **argv,\n>                         struct repository *repo,\n>                         enum output_format format)\n> @@ -97,21 +115,8 @@ static int print_fields(int argc, const char **argv,\n>                 }\n>\n>                 strbuf_reset(&valbuf);\n> -               strbuf_reset(&quotbuf);\n> -\n>                 get_value(repo, &valbuf);\n> -\n> -               switch (format) {\n> -               case FORMAT_KEYVALUE:\n> -                       quote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n> -                       printf(\"%s=%s\\n\", key, quotbuf.buf);\n> -                       break;\n> -               case FORMAT_NUL_TERMINATED:\n> -                       printf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n> -                       break;\n> -               default:\n> -                       BUG(\"not a valid output format: %d\", format);\n> -               }\n> +               print_field(format, key, &valbuf, &quotbuf);\n>         }\n>\n>         strbuf_release(&valbuf);\n"},{"id":"529669","messageId":"CAPig+cRHKySZ+JPs3G0HowdCEJmE9fP=tCFB=DV-KMPknKTZkQ@mail.gmail.com","threadId":"64151","inReplyTo":"CAPig+cQO4_T8K-8wFBDQN-n+rasBF7LR+vJ6ez8swfmDz1ossg@mail.gmail.com","subject":"Re: [PATCH v3 1/2] repo: factor out field printing to dedicated function","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-26T23:56:47Z","receivedAt":"2025-10-26T23:56:59Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Oct 26, 2025 at 7:53 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Sun, Oct 26, 2025 at 6:54 PM Lucas Seiki Oshiro\n> <lucasseikioshiro@gmail.com> wrote:\n> > +       switch (format) {\n> > +       case FORMAT_KEYVALUE:\n> > +               quote_c_style(valbuf->buf, quotbuf, NULL, 0);\n> > +               printf(\"%s=%s\\n\", key, quotbuf->buf);\n> > +               break;\n> > +       case FORMAT_NUL_TERMINATED:\n> > +               printf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n> > +               break;\n> > +       default:\n> > +               BUG(\"not a valid output format: %d\", format);\n> > +       }\n> > +}\n>\n> Moreover, I'd also say that since this is not on a critical path, you\n> should avoid the premature optimization of passing in `strfbuf\n> *quotebuf` and instead make `quotebuf` local to this function.\n>\n>     static void print_field(enum output_format format,\n>         const char *key, const char *value)\n>     {\n>         struct strbuf quotbuf = STRBUF_INIT;\n>         ...stuff...\n>         strbuf_release(&quotbuf);\n>     }\n\nOr, even better, scope the strbuf just to the `case` branch which needs it:\n\n    case FORMAT_KEYVALUE: {\n        struct strbuf buf = STRBUF_INIT;\n        quote_c_style(value, buf, NULL, 0);\n        printf(\"%s=%s\\n\", key, buf->buf);\n        strbuf_release(&buf);\n        break;\n     }\n"},{"id":"529670","messageId":"CAPig+cSOE1Du52Y8-s=b7HvKQyk-XHdGh3XzZR_tVktut9R1YA@mail.gmail.com","threadId":"64151","inReplyTo":"20251026225409.46647-3-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v3 2/2] repo: add --all to git-repo-info","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-27T00:22:25Z","receivedAt":"2025-10-27T00:22:37Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Oct 26, 2025 at 6:54 PM Lucas Seiki Oshiro\n<lucasseikioshiro@gmail.com> wrote:\n> Add a new flag `--all` to git-repo-info for requesting values for all\n> the available keys. By using this flag, the user can retrieve all the\n> values instead of searching what are the desired keys for what they\n> wants.\n>\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n> diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\n> @@ -18,13 +18,13 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n> +`info [--format=(keyvalue|nul)] [-z] [--all | <key>...]`::\n>         Retrieve metadata-related information about the current repository. Only\n>         the requested data will be returned based on their keys (see \"INFO KEYS\"\n>         section below).\n>  +\n>  The values are returned in the same order in which their respective keys were\n> -requested.\n> +requested. The `--all` flag requests the values for all the available keys.\n\nI'm getting mixed signals from this patch. The documentation says that\nit requests all *values*, but... (continued far below)\n\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> @@ -124,6 +124,24 @@ static int print_fields(int argc, const char **argv,\n> +static void print_all_fields(struct repository *repo,\n> +                            enum output_format format)\n> +{\n> +       struct strbuf valbuf = STRBUF_INIT;\n> +       struct strbuf quotbuf = STRBUF_INIT;\n> +\n> +       for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n> +               struct field field = repo_info_fields[i];\n\nWhy do we need to make a copy of the field record? Can't we just use a\nconst pointer?\n\n    struct field *field = &repo_info_fields[i];\n\nor:\n\n   struct field *field = repo_info_fields + i;\n\n> +               strbuf_reset(&valbuf);\n> +               field.get_value(repo, &valbuf);\n> +               print_field(format, field.key, &valbuf, &quotbuf);\n> +       }\n> +\n> +       strbuf_release(&valbuf);\n> +       strbuf_release(&quotbuf);\n> +}\n> @@ -153,11 +172,20 @@ static int repo_info(int argc, const char **argv, const char *prefix,\n> +               OPT_BOOL(0, \"all\", &all_keys, N_(\"return all keys\")),\n\n(continued from above) ...this gives the impression that it's only\nreturning *keys*, but not necessarily the values associated with those\nkeys. Also, \"return\" is a bit unusual in this context; perhaps say\n\"request all keys/values\" or \"print all keys/values\" or something.\n\n>                 OPT_END()\n>         };\n>\n>         argc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n>\n> +       if (all_keys) {\n> +               if (argc)\n> +                       die(_(\"--all and <key> cannot be used together\"));\n> +\n> +               print_all_fields(repo, format);\n> +               return 0;\n> +       }\n> +\n>         return print_fields(argc, argv, repo, format);\n>  }\n>\n> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\n> @@ -4,6 +4,15 @@ test_description='test git repo-info'\n> +# git-repo-info keys. It must contain the same keys listed in the const\n> +# repo_info_fields, in lexicographical order.\n> +REPO_INFO_KEYS='\n> +       layout.bare\n> +       layout.shallow\n> +       object.format\n> +       references.format\n> +'\n\nI'm not a fan of this since it is so brittle. However, I can't think\nof a better alternative at the moment, and we can always revisit it\nlater if it becomes a maintenance burden.\n"},{"id":"529671","messageId":"CAPig+cT3hkBu2kKPQp74JKvO7ct5ooV1wba8xHTzOn_9FGbz7A@mail.gmail.com","threadId":"64151","inReplyTo":"CAPig+cSOE1Du52Y8-s=b7HvKQyk-XHdGh3XzZR_tVktut9R1YA@mail.gmail.com","subject":"Re: [PATCH v3 2/2] repo: add --all to git-repo-info","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-27T00:24:57Z","receivedAt":"2025-10-27T00:25:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Oct 26, 2025 at 8:22 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Sun, Oct 26, 2025 at 6:54 PM Lucas Seiki Oshiro\n> <lucasseikioshiro@gmail.com> wrote:\n> > +       for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n> > +               struct field field = repo_info_fields[i];\n>\n> Why do we need to make a copy of the field record? Can't we just use a\n> const pointer?\n>\n>     struct field *field = &repo_info_fields[i];\n>\n> or:\n>\n>    struct field *field = repo_info_fields + i;\n\nOf course, I mean to have a `const` in there:\n\n    const struct field *field = &repo_info_fields[i];\n"},{"id":"529733","messageId":"xmqqwm4gl7fg.fsf@gitster.g","threadId":"64151","inReplyTo":"CAPig+cRHKySZ+JPs3G0HowdCEJmE9fP=tCFB=DV-KMPknKTZkQ@mail.gmail.com","subject":"Re: [PATCH v3 1/2] repo: factor out field printing to dedicated function","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-27T14:56:35Z","receivedAt":"2025-10-27T14:56:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> Or, even better, scope the strbuf just to the `case` branch which needs it:\n>\n>     case FORMAT_KEYVALUE: {\n>         struct strbuf buf = STRBUF_INIT;\n>         quote_c_style(value, buf, NULL, 0);\n>         printf(\"%s=%s\\n\", key, buf->buf);\n>         strbuf_release(&buf);\n>         break;\n>      }\n\nYuck.  \n\nFor something simple like this, quote_c_style() can take \"FILE *\"\ninstead of struct \"strbuf *\" so that you do not have to allocate;\nespecially without any need for i18n, perhaps\n\n    printf(\"%s=\", key);\n    quote_c_style(value, NULL, stdout, 0);\n\nis sufficient?\n\n"},{"id":"529743","messageId":"CAPig+cThZd3urbiPJ6WiToLcdmaj6AqRpj-edEjiD54Lt_r-1Q@mail.gmail.com","threadId":"64151","inReplyTo":"xmqqwm4gl7fg.fsf@gitster.g","subject":"Re: [PATCH v3 1/2] repo: factor out field printing to dedicated function","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-10-27T16:09:50Z","receivedAt":"2025-10-27T16:10:04Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Oct 27, 2025 at 10:56 AM Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n> > Or, even better, scope the strbuf just to the `case` branch which needs it:\n> >\n> >     case FORMAT_KEYVALUE: {\n> >         struct strbuf buf = STRBUF_INIT;\n> >         quote_c_style(value, buf, NULL, 0);\n> >         printf(\"%s=%s\\n\", key, buf->buf);\n> >         strbuf_release(&buf);\n> >         break;\n> >      }\n>\n> For something simple like this, quote_c_style() can take \"FILE *\"\n> instead of struct \"strbuf *\" so that you do not have to allocate;\n> especially without any need for i18n, perhaps\n>\n>     printf(\"%s=\", key);\n>     quote_c_style(value, NULL, stdout, 0);\n\nThanks, that's even better. Nice and clean and easy to read.\n\n(I didn't have the Git source code at hand, so didn't know that\n`quote_c_style` could take `FILE *`.)\n"},{"id":"530813","messageId":"20251117151844.14802-1-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20250915223618.13093-1-lucasseikioshiro@gmail.com","subject":"[PATCH v4 0/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-17T15:02:50Z","receivedAt":"2025-11-17T15:22:30Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nSorry for only sending this after some weeks. I've been busy finishing\nmy master's and I didn't have enough time to send another version. But\nhere it is.\n\nThis fourth version of this patch addresses the issues pointed by Eric\nin the v3:\n\n- I dropped the `strbuf quotebuf`, since it can be replaced by\n  outputting `quote_c_style` directly to `stdout`;\n\n- `print_field` now uses the string `value` instead of the\n  `strbuf valbuf`;\n\n- The variable `field` in `print_fields` was replaced by a pointer,\n  since it didn't require to be copied;\n\n- replace the help string by the suggested.\n\nLucas Seiki Oshiro (2):\n  repo: factor out field printing to dedicated function\n  repo: add --all to git-repo-info\n\n Documentation/git-repo.adoc |  6 ++--\n builtin/repo.c              | 62 +++++++++++++++++++++++++++----------\n t/t1900-repo.sh             | 21 +++++++++++++\n 3 files changed, 69 insertions(+), 20 deletions(-)\n\nRange-diff against v3:\n1:  0db9aad2bc ! 1:  fce09770b8 repo: factor out field printing to dedicated function\n    @@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)\n      }\n      \n     +static void print_field(enum output_format format, const char *key,\n    -+\t\t\tstruct strbuf *valbuf, struct strbuf *quotbuf)\n    ++\t\t\tconst char *value)\n     +{\n    -+\tstrbuf_reset(quotbuf);\n    -+\n     +\tswitch (format) {\n     +\tcase FORMAT_KEYVALUE:\n    -+\t\tquote_c_style(valbuf->buf, quotbuf, NULL, 0);\n    -+\t\tprintf(\"%s=%s\\n\", key, quotbuf->buf);\n    ++\t\tprintf(\"%s=\", key);\n    ++\t\tquote_c_style(value, NULL, stdout, 0);\n    ++\t\tputchar('\\n');\n     +\t\tbreak;\n     +\tcase FORMAT_NUL_TERMINATED:\n    -+\t\tprintf(\"%s\\n%s%c\", key, valbuf->buf, '\\0');\n    ++\t\tprintf(\"%s\\n%s%c\", key, value, '\\0');\n     +\t\tbreak;\n     +\tdefault:\n     +\t\tBUG(\"not a valid output format: %d\", format);\n    @@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)\n      static int print_fields(int argc, const char **argv,\n      \t\t\tstruct repository *repo,\n      \t\t\tenum output_format format)\n    + {\n    + \tint ret = 0;\n    + \tstruct strbuf valbuf = STRBUF_INIT;\n    +-\tstruct strbuf quotbuf = STRBUF_INIT;\n    + \n    + \tfor (int i = 0; i < argc; i++) {\n    + \t\tget_value_fn *get_value;\n     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n      \t\t}\n      \n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     -\t\tdefault:\n     -\t\t\tBUG(\"not a valid output format: %d\", format);\n     -\t\t}\n    -+\t\tprint_field(format, key, &valbuf, &quotbuf);\n    ++\t\tprint_field(format, key, valbuf.buf);\n      \t}\n      \n      \tstrbuf_release(&valbuf);\n    +-\tstrbuf_release(&quotbuf);\n    + \treturn ret;\n    + }\n    + \n2:  b6ecdc2c2f ! 2:  ccdad86123 repo: add --all to git-repo-info\n    @@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor\n      [synopsis]\n     -git repo info [--format=(keyvalue|nul)] [-z] [<key>...]\n     +git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n    + git repo structure [--format=(table|keyvalue|nul)]\n      \n      DESCRIPTION\n    - -----------\n     @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n      \n      COMMANDS\n    @@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN\n     \n      ## builtin/repo.c ##\n     @@\n    - #include \"shallow.h\"\n    + #include \"utf8.h\"\n      \n      static const char *const repo_usage[] = {\n     -\t\"git repo info [--format=(keyvalue|nul)] [-z] [<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    - \n     @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n      \treturn ret;\n      }\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     +\t\t\t     enum output_format format)\n     +{\n     +\tstruct strbuf valbuf = STRBUF_INIT;\n    -+\tstruct strbuf quotbuf = STRBUF_INIT;\n     +\n     +\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n    -+\t\tstruct field field = repo_info_fields[i];\n    ++\t\tconst struct field *field = &repo_info_fields[i];\n     +\n     +\t\tstrbuf_reset(&valbuf);\n    -+\t\tfield.get_value(repo, &valbuf);\n    -+\t\tprint_field(format, field.key, &valbuf, &quotbuf);\n    ++\t\tfield->get_value(repo, &valbuf);\n    ++\t\tprint_field(format, field->key, valbuf.buf);\n     +\t}\n     +\n     +\tstrbuf_release(&valbuf);\n    -+\tstrbuf_release(&quotbuf);\n     +}\n     +\n      static int parse_format_cb(const struct option *opt,\n      \t\t\t   const char *arg, int unset UNUSED)\n      {\n    -@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,\n    - \t\t     struct repository *repo)\n    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n    + \t\t\t struct repository *repo)\n      {\n      \tenum output_format format = FORMAT_KEYVALUE;\n     +\tint all_keys = 0;\n      \tstruct option options[] = {\n      \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n      \t\t\t       N_(\"output format\"),\n    -@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,\n    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"return all keys\")),\n    ++\t\tOPT_BOOL(0, \"all\", &all_keys, N_(\"print all keys/values\")),\n      \t\tOPT_END()\n      \t};\n      \n    - \targc = parse_options(argc, argv, prefix, options, repo_usage, 0);\n    +@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n    + \tif (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)\n    + \t\tdie(_(\"unsupported output format\"));\n      \n     +\tif (all_keys) {\n     +\t\tif (argc)\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530814","messageId":"20251117151844.14802-2-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251117151844.14802-1-lucasseikioshiro@gmail.com","subject":"[PATCH v4 1/2] repo: factor out field printing to dedicated function","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-17T15:02:51Z","receivedAt":"2025-11-17T15:22:32Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Move the field printing in git-repo-info to a new function called\n`print_field`, allowing it to be called by functions other than\n`print_fields`.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n builtin/repo.c | 34 ++++++++++++++++++----------------\n 1 file changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 9d4749f79b..f9fb418494 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -85,13 +85,29 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n \treturn found ? found->get_value : NULL;\n }\n \n+static void print_field(enum output_format format, const char *key,\n+\t\t\tconst char *value)\n+{\n+\tswitch (format) {\n+\tcase FORMAT_KEYVALUE:\n+\t\tprintf(\"%s=\", key);\n+\t\tquote_c_style(value, NULL, stdout, 0);\n+\t\tputchar('\\n');\n+\t\tbreak;\n+\tcase FORMAT_NUL_TERMINATED:\n+\t\tprintf(\"%s\\n%s%c\", key, value, '\\0');\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"not a valid output format: %d\", format);\n+\t}\n+}\n+\n static int print_fields(int argc, const char **argv,\n \t\t\tstruct repository *repo,\n \t\t\tenum output_format format)\n {\n \tint ret = 0;\n \tstruct strbuf valbuf = STRBUF_INIT;\n-\tstruct strbuf quotbuf = STRBUF_INIT;\n \n \tfor (int i = 0; i < argc; i++) {\n \t\tget_value_fn *get_value;\n@@ -105,25 +121,11 @@ static int print_fields(int argc, const char **argv,\n \t\t}\n \n \t\tstrbuf_reset(&valbuf);\n-\t\tstrbuf_reset(&quotbuf);\n-\n \t\tget_value(repo, &valbuf);\n-\n-\t\tswitch (format) {\n-\t\tcase FORMAT_KEYVALUE:\n-\t\t\tquote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n-\t\t\tprintf(\"%s=%s\\n\", key, quotbuf.buf);\n-\t\t\tbreak;\n-\t\tcase FORMAT_NUL_TERMINATED:\n-\t\t\tprintf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tBUG(\"not a valid output format: %d\", format);\n-\t\t}\n+\t\tprint_field(format, key, valbuf.buf);\n \t}\n \n \tstrbuf_release(&valbuf);\n-\tstrbuf_release(&quotbuf);\n \treturn ret;\n }\n \n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530815","messageId":"20251117151844.14802-3-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251117151844.14802-1-lucasseikioshiro@gmail.com","subject":"[PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-17T15:02:52Z","receivedAt":"2025-11-17T15:22:35Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Add a new flag `--all` to git-repo-info for requesting values for all\nthe available keys. By using this flag, the user can retrieve all the\nvalues instead of searching what are the desired keys for what they\nwants.\n\nHelped-by: Karthik Nayak <karthik.188@gmail.com>\nHelped-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              | 28 +++++++++++++++++++++++++++-\n t/t1900-repo.sh             | 21 +++++++++++++++++++++\n 3 files changed, 51 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex ce43cb19c8..70f0a6d2e4 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] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n git repo structure [--format=(table|keyvalue|nul)]\n \n DESCRIPTION\n@@ -19,13 +19,13 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [-z] [<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).\n +\n The values are returned in the same order in which their respective keys were\n-requested.\n+requested. The `--all` flag requests the values for all the available keys.\n +\n The output format can be chosen through the flag `--format`. Two formats are\n supported:\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex f9fb418494..22a9ecb3a1 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] [<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@@ -129,6 +129,22 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static void print_all_fields(struct repository *repo,\n+\t\t\t     enum output_format format)\n+{\n+\tstruct strbuf valbuf = STRBUF_INIT;\n+\n+\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n+\t\tconst struct field *field = &repo_info_fields[i];\n+\n+\t\tstrbuf_reset(&valbuf);\n+\t\tfield->get_value(repo, &valbuf);\n+\t\tprint_field(format, field->key, valbuf.buf);\n+\t}\n+\n+\tstrbuf_release(&valbuf);\n+}\n+\n static int parse_format_cb(const struct option *opt,\n \t\t\t   const char *arg, int unset UNUSED)\n {\n@@ -152,6 +168,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n \t\t\t struct repository *repo)\n {\n \tenum output_format format = FORMAT_KEYVALUE;\n+\tint all_keys = 0;\n \tstruct option options[] = {\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n@@ -160,6 +177,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"print all keys/values\")),\n \t\tOPT_END()\n \t};\n \n@@ -167,6 +185,14 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n \tif (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)\n \t\tdie(_(\"unsupported output format\"));\n \n+\tif (all_keys) {\n+\t\tif (argc)\n+\t\t\tdie(_(\"--all and <key> cannot be used together\"));\n+\n+\t\tprint_all_fields(repo, format);\n+\t\treturn 0;\n+\t}\n+\n \treturn print_fields(argc, argv, repo, format);\n }\n \ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 2beba67889..51d55f11a5 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -4,6 +4,15 @@ test_description='test git repo-info'\n \n . ./test-lib.sh\n \n+# git-repo-info keys. It must contain the same keys listed in the const\n+# repo_info_fields, in lexicographical order.\n+REPO_INFO_KEYS='\n+\tlayout.bare\n+\tlayout.shallow\n+\tobject.format\n+\treferences.format\n+'\n+\n # Test whether a key-value pair is correctly returned\n #\n # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>\n@@ -110,4 +119,16 @@ test_expect_success 'git repo info uses the last requested format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'git repo info --all returns all key-value pairs' '\n+\tgit repo info $REPO_INFO_KEYS >expect &&\n+\tgit repo info --all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git repo info --all <key> aborts' '\n+\techo \"fatal: --all and <key> cannot be used together\" >expect &&\n+\ttest_must_fail git repo info --all object.format 2>actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530827","messageId":"xmqq346cle5h.fsf@gitster.g","threadId":"64151","inReplyTo":"20251117151844.14802-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v4 0/2] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-17T18:14:50Z","receivedAt":"2025-11-17T18:14:53Z","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 fourth version of this patch addresses the issues pointed by Eric\n> in the v3:\n>\n> - I dropped the `strbuf quotebuf`, since it can be replaced by\n>   outputting `quote_c_style` directly to `stdout`;\n>\n> - `print_field` now uses the string `value` instead of the\n>   `strbuf valbuf`;\n>\n> - The variable `field` in `print_fields` was replaced by a pointer,\n>   since it didn't require to be copied;\n>\n> - replace the help string by the suggested.\n\nAll changes relative to v3 look sensible to me, but I'll have to see\nwhat is outside range-diff (i.e., what was done before v3 and\nremains in this iteration), too.\n\nThanks.\n\n"},{"id":"530830","messageId":"xmqqldk4ijgd.fsf@gitster.g","threadId":"64151","inReplyTo":"20251117151844.14802-2-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v4 1/2] repo: factor out field printing to dedicated function","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-17T18:48:34Z","receivedAt":"2025-11-17T18:48:37Z","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> Move the field printing in git-repo-info to a new function called\n> `print_field`, allowing it to be called by functions other than\n> `print_fields`.\n\nMissing:\n\n    Also change its use of quote_c_style() helper to output directly to\n    the standard output stream, instead of taking a result in a strbuf\n    and then printing it outselves.\n\nThe patch text looks great.\n\n> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n> ---\n>  builtin/repo.c | 34 ++++++++++++++++++----------------\n>  1 file changed, 18 insertions(+), 16 deletions(-)\n>\n> diff --git a/builtin/repo.c b/builtin/repo.c\n> index 9d4749f79b..f9fb418494 100644\n> --- a/builtin/repo.c\n> +++ b/builtin/repo.c\n> @@ -85,13 +85,29 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n>  \treturn found ? found->get_value : NULL;\n>  }\n>  \n> +static void print_field(enum output_format format, const char *key,\n> +\t\t\tconst char *value)\n> +{\n> +\tswitch (format) {\n> +\tcase FORMAT_KEYVALUE:\n> +\t\tprintf(\"%s=\", key);\n> +\t\tquote_c_style(value, NULL, stdout, 0);\n> +\t\tputchar('\\n');\n> +\t\tbreak;\n> +\tcase FORMAT_NUL_TERMINATED:\n> +\t\tprintf(\"%s\\n%s%c\", key, value, '\\0');\n> +\t\tbreak;\n> +\tdefault:\n> +\t\tBUG(\"not a valid output format: %d\", format);\n> +\t}\n> +}\n> +\n>  static int print_fields(int argc, const char **argv,\n>  \t\t\tstruct repository *repo,\n>  \t\t\tenum output_format format)\n>  {\n>  \tint ret = 0;\n>  \tstruct strbuf valbuf = STRBUF_INIT;\n> -\tstruct strbuf quotbuf = STRBUF_INIT;\n>  \n>  \tfor (int i = 0; i < argc; i++) {\n>  \t\tget_value_fn *get_value;\n> @@ -105,25 +121,11 @@ static int print_fields(int argc, const char **argv,\n>  \t\t}\n>  \n>  \t\tstrbuf_reset(&valbuf);\n> -\t\tstrbuf_reset(&quotbuf);\n> -\n>  \t\tget_value(repo, &valbuf);\n> -\n> -\t\tswitch (format) {\n> -\t\tcase FORMAT_KEYVALUE:\n> -\t\t\tquote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n> -\t\t\tprintf(\"%s=%s\\n\", key, quotbuf.buf);\n> -\t\t\tbreak;\n> -\t\tcase FORMAT_NUL_TERMINATED:\n> -\t\t\tprintf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n> -\t\t\tbreak;\n> -\t\tdefault:\n> -\t\t\tBUG(\"not a valid output format: %d\", format);\n> -\t\t}\n> +\t\tprint_field(format, key, valbuf.buf);\n>  \t}\n>  \n>  \tstrbuf_release(&valbuf);\n> -\tstrbuf_release(&quotbuf);\n>  \treturn ret;\n>  }\n"},{"id":"530831","messageId":"xmqqh5usiizp.fsf@gitster.g","threadId":"64151","inReplyTo":"20251117151844.14802-3-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-17T18:58:34Z","receivedAt":"2025-11-17T18:58:37Z","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> +static void print_all_fields(struct repository *repo,\n> +\t\t\t     enum output_format format)\n> +{\n> +\tstruct strbuf valbuf = STRBUF_INIT;\n> +\n> +\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n> +\t\tconst struct field *field = &repo_info_fields[i];\n> +\n> +\t\tstrbuf_reset(&valbuf);\n> +\t\tfield->get_value(repo, &valbuf);\n> +\t\tprint_field(format, field->key, valbuf.buf);\n> +\t}\n> +\tstrbuf_release(&valbuf);\n> +}\n\nI am not sure if \"unsigned long i\" is the type you want here.  I do\nnot mind, and actually I prefer, a simple platform natural \"int i\"\nfor something simple like this [*], but I know other people prefer to\nuse \"size_t\" to work with ARRAY_SIZE() these days.\n\n    Side note: The reason they insist using size_t here is that\n        \"-Wsign-compare\" makes the compiler complain.  But I would\n        say that it only shows what a misguided feature\n        -Wsign-compare warning is, especially given that the\n        compiler perfectly well knows how big repo_info_fields[]\n        array is and the iteration cannot do any harm if done with a\n        signed integer smaller than size_t\n\nAnyway.\n\nWe grab each field, ask it for its value, and then print it.  What a\nstraight-forward flow that is pleasant to read! ;-).\n\nCompared to that, printing of individual keys given by the end-user\nis much uglier, but it is not a fault of this two-patch series, so\nmy comment here is only as #leftoverbits for later clean-up.\n\nThe print_fields() function does this (modulo error checking for\nmissing key):\n\n\tfor (int i = 0; i < argc; i++) {\n\t\tget_value_fn *get_value;\n\t\tconst char *key = argv[i];\n\n\t\tget_value = get_value_fn_for_key(key);\n\t\tget_value(repo, &valbuf);\n\nWe should get rid of the get_value_fn_for_key() helper, and instead\nadd and use repo_info_field(const char *key) helepr.  That way, the\nlogic become exactly the same as the \"get all\" case.  The body of\nthe loop would read (modulo error checking for missing key):\n\n\t\tconst struct field *field = repo_info_field(argv[i]);\n\t        field->get_value(repo, &valbuf);\n\nwhcih is much nicer, when the repo_info_fields[] gains more\nattributes other than a callback function, we do not want to keep\nadding get_this_attr_for_key() functions.\n\n    Side note: By the way, it should be named repo_info_field[].\n        Name arrays singular so that you can name its 0th element by\n        saying dog[0], not dogs[0].  \"dog[1] and dog[2] are friends\"\n        not \"dogs[1] and dogs[2] are friends\".  An exception is when\n        most of the time you use the array as a single unit as a\n        collection, passing it around in the call chain, and you\n        rarely address each individual element (other than outside\n        the implementation of the API).  I am OK to see such an\n        array that is mostly used as a collection named plural (but\n        of course, singular names are always fine).  Adding this to\n        CodingGuidelines is perhaps a #leftoverbits material.\n\n> @@ -167,6 +185,14 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n>  \tif (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)\n>  \t\tdie(_(\"unsupported output format\"));\n>  \n> +\tif (all_keys) {\n> +\t\tif (argc)\n> +\t\t\tdie(_(\"--all and <key> cannot be used together\"));\n> +\n> +\t\tprint_all_fields(repo, format);\n> +\t\treturn 0;\n> +\t}\n>  \treturn print_fields(argc, argv, repo, format);\n\nThis would work, but the symmetry between a list of keys vs the\n\"--all\" option is lost.\n\nI'd rather see something like the following after a #leftoverbits\nclean-up commit:\n\n\tif (all_keys && argc)\n\t\tdie(_(\"--all and <key> cannot be used together\"));\n\n\tif (all_keys)\n\t\treturn print_all_fields(repo, format);\n\telse\n\t\treturn print_fields(argc, argv, repo, format);\n\n> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\n> index 2beba67889..51d55f11a5 100755\n> --- a/t/t1900-repo.sh\n> +++ b/t/t1900-repo.sh\n> @@ -4,6 +4,15 @@ test_description='test git repo-info'\n>  \n>  . ./test-lib.sh\n>  \n> +# git-repo-info keys. It must contain the same keys listed in the const\n> +# repo_info_fields, in lexicographical order.\n> +REPO_INFO_KEYS='\n> +\tlayout.bare\n> +\tlayout.shallow\n> +\tobject.format\n> +\treferences.format\n> +'\n\nAgain, this would work for now, but maybe \"git repo info --keys\"\nthat emits these would be easier to manage.  This can be left to\n#leftoverbits of course.\n\nBut then we have seem to have seen too many #leftoverbits material,\nyou might want to handle some or all of them in this series in a\nreroll?  I am starting to become undecided.\n\nWith \"repo info --keys\", the user could even do\n\n    git repo info $(git repo info --keys)\n\nif they wanted to.\n\nNo, I am not suggesting to discard the \"--all\" option; only pointing\nout that conceptually, \"--all\" can be explained in terms of\n\"--keys\".\n"},{"id":"530920","messageId":"DA3814BC-D6A5-4EF1-9A2B-9687D1B6C26A@gmail.com","threadId":"64151","inReplyTo":"xmqqh5usiizp.fsf@gitster.g","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-18T20:16:09Z","receivedAt":"2025-11-18T20:16:23Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n>> + for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n>> \n> I am not sure if \"unsigned long i\" is the type you want here.  I do\n> not mind, and actually I prefer, a simple platform natural \"int i\"\n> for something simple like this [*], but I know other people prefer to\n> use \"size_t\" to work with ARRAY_SIZE() these days.\n\nYeah, I also thought it an unsigned long feels out of place, but I\nwas only following ARRAY_SIZE. Actually, I was trying to avoid a\nwarning. In this case we have very few `repo_info_field`s and any\nint type would work here...\n\nI'll replace it by size_t, then.\n\n>    Side note: The reason they insist using size_t here is that\n>        \"-Wsign-compare\" makes the compiler complain.  But I would\n>        say that it only shows what a misguided feature\n>        -Wsign-compare warning is, especially given that the\n>        compiler perfectly well knows how big repo_info_fields[]\n>        array is and the iteration cannot do any harm if done with a\n>        signed integer smaller than size_t\n\nPerhaps if ARRAY_SIZE(repo_info_fields) is bigger than the maximum\nlimit of the integer type, which would overflow and this for would\nloop forever. But, obviously this wouldn't happen here.\n\n> This would work, but the symmetry between a list of keys vs the\n> \"--all\" option is lost.\n> \n> I'd rather see something like the following after a #leftoverbits\n> clean-up commit:\n> \n> if (all_keys && argc)\n> die(_(\"--all and <key> cannot be used together\"));\n> \n> if (all_keys)\n> return print_all_fields(repo, format);\n> else\n> return print_fields(argc, argv, repo, format);\n\nI'll change it in v5.\n\n> Again, this would work for now, but maybe \"git repo info --keys\"\n> that emits these would be easier to manage.  This can be left to\n> #leftoverbits of course.\n\nI can't see a use for it other than these tests. What about writing\na helper inside t/helpers for that?\n\n> But then we have seem to have seen too many #leftoverbits material,\n> you might want to handle some or all of them in this series in a\n> reroll?  I am starting to become undecided.\n\nI agree with all of them, but I think they were too much for this\nseries... I also think that after git-repo-structure being added to\nrepo.c I think that it deserves a patchset only for refactoring.\n\nBut I'll send a v5 containing the changes directly related to this\nseries.\n\nThanks again. I'll send a v5 soon.\n\n"},{"id":"530921","messageId":"20251118204929.43597-1-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20250915223618.13093-1-lucasseikioshiro@gmail.com","subject":"[PATCH v5 0/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-18T20:37:02Z","receivedAt":"2025-11-18T20:49:55Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\nThis v5 addresses the issues pointed by Junio in the previous versions. They\nare two small changes:\n\n- `print_all_fields` now has the same signature `print_fields`\n\n- now it uses `size_t` instead of `unsigned long` in a `for` loop\n\nLucas Seiki Oshiro (2):\n  repo: factor out field printing to dedicated function\n  repo: add --all to git-repo-info\n\n Documentation/git-repo.adoc |  6 ++--\n builtin/repo.c              | 63 ++++++++++++++++++++++++++-----------\n t/t1900-repo.sh             | 21 +++++++++++++\n 3 files changed, 69 insertions(+), 21 deletions(-)\n\nRange-diff against v4:\n1:  fce09770b8 ! 1:  c792715fdd repo: factor out field printing to dedicated function\n    @@ Commit message\n         `print_field`, allowing it to be called by functions other than\n         `print_fields`.\n     \n    +    Also change its use of quote_c_style() helper to output directly to\n    +    the standard output stream, instead of taking a result in a strbuf\n    +    and then printing it outselves.\n    +\n         Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n     \n      ## builtin/repo.c ##\n2:  ccdad86123 ! 2:  b309d0e13c repo: add --all to git-repo-info\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n      \treturn ret;\n      }\n      \n    -+static void print_all_fields(struct repository *repo,\n    -+\t\t\t     enum output_format format)\n    ++static int print_all_fields(struct repository *repo,\n    ++\t\t\t    enum output_format format)\n     +{\n     +\tstruct strbuf valbuf = STRBUF_INIT;\n     +\n    -+\tfor (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n    ++\tfor (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n     +\t\tconst struct field *field = &repo_info_fields[i];\n     +\n     +\t\tstrbuf_reset(&valbuf);\n    @@ builtin/repo.c: static int print_fields(int argc, const char **argv,\n     +\t}\n     +\n     +\tstrbuf_release(&valbuf);\n    ++\treturn 0;\n     +}\n     +\n      static int parse_format_cb(const struct option *opt,\n    @@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char\n      \tif (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)\n      \t\tdie(_(\"unsupported output format\"));\n      \n    -+\tif (all_keys) {\n    -+\t\tif (argc)\n    -+\t\t\tdie(_(\"--all and <key> cannot be used together\"));\n    +-\treturn print_fields(argc, argv, repo, format);\n    ++\tif (all_keys && argc)\n    ++\t\tdie(_(\"--all and <key> cannot be used together\"));\n     +\n    -+\t\tprint_all_fields(repo, format);\n    -+\t\treturn 0;\n    -+\t}\n    -+\n    - \treturn print_fields(argc, argv, repo, format);\n    ++\tif (all_keys)\n    ++\t\treturn print_all_fields(repo, format);\n    ++\telse\n    ++\t\treturn print_fields(argc, argv, repo, format);\n      }\n      \n    + struct ref_stats {\n     \n      ## t/t1900-repo.sh ##\n     @@ t/t1900-repo.sh: test_description='test git repo-info'\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530922","messageId":"20251118204929.43597-2-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251118204929.43597-1-lucasseikioshiro@gmail.com","subject":"[PATCH v5 1/2] repo: factor out field printing to dedicated function","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-18T20:37:03Z","receivedAt":"2025-11-18T20:49:57Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Move the field printing in git-repo-info to a new function called\n`print_field`, allowing it to be called by functions other than\n`print_fields`.\n\nAlso change its use of quote_c_style() helper to output directly to\nthe standard output stream, instead of taking a result in a strbuf\nand then printing it outselves.\n\nSigned-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>\n---\n builtin/repo.c | 34 ++++++++++++++++++----------------\n 1 file changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 9d4749f79b..f9fb418494 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -85,13 +85,29 @@ static get_value_fn *get_value_fn_for_key(const char *key)\n \treturn found ? found->get_value : NULL;\n }\n \n+static void print_field(enum output_format format, const char *key,\n+\t\t\tconst char *value)\n+{\n+\tswitch (format) {\n+\tcase FORMAT_KEYVALUE:\n+\t\tprintf(\"%s=\", key);\n+\t\tquote_c_style(value, NULL, stdout, 0);\n+\t\tputchar('\\n');\n+\t\tbreak;\n+\tcase FORMAT_NUL_TERMINATED:\n+\t\tprintf(\"%s\\n%s%c\", key, value, '\\0');\n+\t\tbreak;\n+\tdefault:\n+\t\tBUG(\"not a valid output format: %d\", format);\n+\t}\n+}\n+\n static int print_fields(int argc, const char **argv,\n \t\t\tstruct repository *repo,\n \t\t\tenum output_format format)\n {\n \tint ret = 0;\n \tstruct strbuf valbuf = STRBUF_INIT;\n-\tstruct strbuf quotbuf = STRBUF_INIT;\n \n \tfor (int i = 0; i < argc; i++) {\n \t\tget_value_fn *get_value;\n@@ -105,25 +121,11 @@ static int print_fields(int argc, const char **argv,\n \t\t}\n \n \t\tstrbuf_reset(&valbuf);\n-\t\tstrbuf_reset(&quotbuf);\n-\n \t\tget_value(repo, &valbuf);\n-\n-\t\tswitch (format) {\n-\t\tcase FORMAT_KEYVALUE:\n-\t\t\tquote_c_style(valbuf.buf, &quotbuf, NULL, 0);\n-\t\t\tprintf(\"%s=%s\\n\", key, quotbuf.buf);\n-\t\t\tbreak;\n-\t\tcase FORMAT_NUL_TERMINATED:\n-\t\t\tprintf(\"%s\\n%s%c\", key, valbuf.buf, '\\0');\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tBUG(\"not a valid output format: %d\", format);\n-\t\t}\n+\t\tprint_field(format, key, valbuf.buf);\n \t}\n \n \tstrbuf_release(&valbuf);\n-\tstrbuf_release(&quotbuf);\n \treturn ret;\n }\n \n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530923","messageId":"20251118204929.43597-3-lucasseikioshiro@gmail.com","threadId":"64151","inReplyTo":"20251118204929.43597-1-lucasseikioshiro@gmail.com","subject":"[PATCH v5 2/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-18T20:37:04Z","receivedAt":"2025-11-18T20:49:59Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Add a new flag `--all` to git-repo-info for requesting values for all\nthe available keys. By using this flag, the user can retrieve all the\nvalues instead of searching what are the desired keys for what they\nwants.\n\nHelped-by: Karthik Nayak <karthik.188@gmail.com>\nHelped-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              | 29 +++++++++++++++++++++++++++--\n t/t1900-repo.sh             | 21 +++++++++++++++++++++\n 3 files changed, 51 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex ce43cb19c8..70f0a6d2e4 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] [<key>...]\n+git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]\n git repo structure [--format=(table|keyvalue|nul)]\n \n DESCRIPTION\n@@ -19,13 +19,13 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.\n \n COMMANDS\n --------\n-`info [--format=(keyvalue|nul)] [-z] [<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).\n +\n The values are returned in the same order in which their respective keys were\n-requested.\n+requested. The `--all` flag requests the values for all the available keys.\n +\n The output format can be chosen through the flag `--format`. Two formats are\n supported:\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex f9fb418494..e30e2416d4 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] [<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@@ -129,6 +129,23 @@ static int print_fields(int argc, const char **argv,\n \treturn ret;\n }\n \n+static int print_all_fields(struct repository *repo,\n+\t\t\t    enum output_format format)\n+{\n+\tstruct strbuf valbuf = STRBUF_INIT;\n+\n+\tfor (size_t i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n+\t\tconst struct field *field = &repo_info_fields[i];\n+\n+\t\tstrbuf_reset(&valbuf);\n+\t\tfield->get_value(repo, &valbuf);\n+\t\tprint_field(format, field->key, valbuf.buf);\n+\t}\n+\n+\tstrbuf_release(&valbuf);\n+\treturn 0;\n+}\n+\n static int parse_format_cb(const struct option *opt,\n \t\t\t   const char *arg, int unset UNUSED)\n {\n@@ -152,6 +169,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n \t\t\t struct repository *repo)\n {\n \tenum output_format format = FORMAT_KEYVALUE;\n+\tint all_keys = 0;\n \tstruct option options[] = {\n \t\tOPT_CALLBACK_F(0, \"format\", &format, N_(\"format\"),\n \t\t\t       N_(\"output format\"),\n@@ -160,6 +178,7 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\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, \"all\", &all_keys, N_(\"print all keys/values\")),\n \t\tOPT_END()\n \t};\n \n@@ -167,7 +186,13 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,\n \tif (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)\n \t\tdie(_(\"unsupported output format\"));\n \n-\treturn print_fields(argc, argv, repo, format);\n+\tif (all_keys && argc)\n+\t\tdie(_(\"--all and <key> cannot be used together\"));\n+\n+\tif (all_keys)\n+\t\treturn print_all_fields(repo, format);\n+\telse\n+\t\treturn print_fields(argc, argv, repo, format);\n }\n \n struct ref_stats {\ndiff --git a/t/t1900-repo.sh b/t/t1900-repo.sh\nindex 2beba67889..51d55f11a5 100755\n--- a/t/t1900-repo.sh\n+++ b/t/t1900-repo.sh\n@@ -4,6 +4,15 @@ test_description='test git repo-info'\n \n . ./test-lib.sh\n \n+# git-repo-info keys. It must contain the same keys listed in the const\n+# repo_info_fields, in lexicographical order.\n+REPO_INFO_KEYS='\n+\tlayout.bare\n+\tlayout.shallow\n+\tobject.format\n+\treferences.format\n+'\n+\n # Test whether a key-value pair is correctly returned\n #\n # Usage: test_repo_info <label> <init command> <repo_name> <key> <expected value>\n@@ -110,4 +119,16 @@ test_expect_success 'git repo info uses the last requested format' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'git repo info --all returns all key-value pairs' '\n+\tgit repo info $REPO_INFO_KEYS >expect &&\n+\tgit repo info --all >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git repo info --all <key> aborts' '\n+\techo \"fatal: --all and <key> cannot be used together\" >expect &&\n+\ttest_must_fail git repo info --all object.format 2>actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.50.1 (Apple Git-155)\n\n"},{"id":"530925","messageId":"xmqq8qg3do99.fsf@gitster.g","threadId":"64151","inReplyTo":"DA3814BC-D6A5-4EF1-9A2B-9687D1B6C26A@gmail.com","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-18T21:28:18Z","receivedAt":"2025-11-18T21:28:21Z","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>>> + for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {\n>>> \n>> I am not sure if \"unsigned long i\" is the type you want here.  I do\n>> not mind, and actually I prefer, a simple platform natural \"int i\"\n>> for something simple like this [*], but I know other people prefer to\n>> use \"size_t\" to work with ARRAY_SIZE() these days.\n>\n> Yeah, I also thought it an unsigned long feels out of place, but I\n> was only following ARRAY_SIZE. Actually, I was trying to avoid a\n> warning. In this case we have very few `repo_info_field`s and any\n> int type would work here...\n>\n> I'll replace it by size_t, then.\n>\n>>    Side note: The reason they insist using size_t here is that\n>>        \"-Wsign-compare\" makes the compiler complain.  But I would\n>>        say that it only shows what a misguided feature\n>>        -Wsign-compare warning is, especially given that the\n>>        compiler perfectly well knows how big repo_info_fields[]\n>>        array is and the iteration cannot do any harm if done with a\n>>        signed integer smaller than size_t\n>\n> Perhaps if ARRAY_SIZE(repo_info_fields) is bigger than the maximum\n> limit of the integer type, which would overflow and this for would\n> loop forever. But, obviously this wouldn't happen here.\n\nYes.  We can tell, and a compiler should be able to figure out, that\ninside the loop nothing other than increment by one per iteration is\ndone to \"i\", and the ARRAY_SIZE(repo_info_fields) is a compile-time\nconstant that comfortably fits in platform natural \"int\", so we\nknow, and a compiler should know, that there is nothing to complain\nabout if \"int i\" is used there.\n\nBut the quality of implementation of -Wsign-compare may not be good\nenough to figure it out.\n\nAs ARRAY_SIZE() essentially is a size_t divided by another size_t,\nuse of size_t is the safest solution that does not require any\nbraincycle to pick.\n\n>> Again, this would work for now, but maybe \"git repo info --keys\"\n>> that emits these would be easier to manage.  This can be left to\n>> #leftoverbits of course.\n>\n> I can't see a use for it other than these tests. What about writing\n> a helper inside t/helpers for that?\n\nIf you use \"git repo info\" only occasionally, wouldn't \"git repo\ninfo --keys\", if supported, be a useful way to get a more focused\nhelp than \"git repo --help\" where you have to scan the entire\ndocument and try to find the list of keys that are supported from\nthere?\n"},{"id":"530926","messageId":"xmqq4iqrdnyx.fsf@gitster.g","threadId":"64151","inReplyTo":"20251118204929.43597-1-lucasseikioshiro@gmail.com","subject":"Re: [PATCH v5 0/2] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-18T21:34:30Z","receivedAt":"2025-11-18T21:34:33Z","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 v5 addresses the issues pointed by Junio in the previous versions. They\n> are two small changes:\n>\n> - `print_all_fields` now has the same signature `print_fields`\n>\n> - now it uses `size_t` instead of `unsigned long` in a `for` loop\n>\n> Lucas Seiki Oshiro (2):\n>   repo: factor out field printing to dedicated function\n>   repo: add --all to git-repo-info\n>\n>  Documentation/git-repo.adoc |  6 ++--\n>  builtin/repo.c              | 63 ++++++++++++++++++++++++++-----------\n>  t/t1900-repo.sh             | 21 +++++++++++++\n>  3 files changed, 69 insertions(+), 21 deletions(-)\n\nLooking good.  Will replace.\n\nShall we mark the topic for 'next' now?\n\nThanks.\n"},{"id":"530948","messageId":"CAPig+cSMOEWUZPfLQJBWpAgK-cvAUMgD1t2KsVVAMWn30ngwiw@mail.gmail.com","threadId":"64151","inReplyTo":"xmqqh5usiizp.fsf@gitster.g","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-11-19T07:32:22Z","receivedAt":"2025-11-19T07:32:34Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 17, 2025 at 1:58 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n> > +     if (all_keys) {\n> > +             if (argc)\n> > +                     die(_(\"--all and <key> cannot be used together\"));\n> > +\n> > +             print_all_fields(repo, format);\n> > +             return 0;\n> > +     }\n> >       return print_fields(argc, argv, repo, format);\n>\n> This would work, but the symmetry between a list of keys vs the\n> \"--all\" option is lost.\n>\n> I'd rather see something like the following after a #leftoverbits\n> clean-up commit:\n>\n>         if (all_keys && argc)\n>                 die(_(\"--all and <key> cannot be used together\"));\n>\n>         if (all_keys)\n>                 return print_all_fields(repo, format);\n>         else\n>                 return print_fields(argc, argv, repo, format);\n\nFor what it's worth, I had the same reaction when reviewing the\nprevious version, and thought about proposing the same rewrite but\nfigured that such a comment might fall into the \"too subjective\"\ncategory, thus omitted it from my review.\n"},{"id":"530949","messageId":"CAPig+cRG3qR0osmFk=F93mf4di+i4WHWemu=_WDUeD0Vz9pO9A@mail.gmail.com","threadId":"64151","inReplyTo":"xmqq4iqrdnyx.fsf@gitster.g","subject":"Re: [PATCH v5 0/2] repo: add --all to git-repo-info","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-11-19T07:35:56Z","receivedAt":"2025-11-19T07:36:08Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Nov 18, 2025 at 4:34 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n> > This v5 addresses the issues pointed by Junio in the previous versions. They\n> > are two small changes:\n> >\n> > - `print_all_fields` now has the same signature `print_fields`\n> >\n> > - now it uses `size_t` instead of `unsigned long` in a `for` loop\n>\n> Looking good.  Will replace.\n>\n> Shall we mark the topic for 'next' now?\n\nI think all my review comments have been addressed.\n"},{"id":"530990","messageId":"xmqqfraacct8.fsf@gitster.g","threadId":"64151","inReplyTo":"CAPig+cSMOEWUZPfLQJBWpAgK-cvAUMgD1t2KsVVAMWn30ngwiw@mail.gmail.com","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-11-19T14:33:07Z","receivedAt":"2025-11-19T14:33:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> For what it's worth, I had the same reaction when reviewing the\n> previous version, and thought about proposing the same rewrite but\n> figured that such a comment might fall into the \"too subjective\"\n> category, thus omitted it from my review.\n\nHeh, then that makes the subjectiveness a bit weaker? ;-)\n"},{"id":"531090","messageId":"5F1F88D3-7EDD-4576-B692-4632E0086E8F@gmail.com","threadId":"64151","inReplyTo":"xmqq8qg3do99.fsf@gitster.g","subject":"Re: [PATCH v4 2/2] repo: add --all to git-repo-info","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-11-20T22:50:09Z","receivedAt":"2025-11-20T22:50:24Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> If you use \"git repo info\" only occasionally, wouldn't \"git repo\n> info --keys\", if supported, be a useful way to get a more focused\n> help than \"git repo --help\" where you have to scan the entire\n> document and try to find the list of keys that are supported from\n> there?\n\nHmmm, ok, makes sense. After sending the previous message,\nI also thought about it being used for shell completions by\nfish or zsh, for example.\n"}]}