From: Junio C Hamano <gitster@pobox•com>
To: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Cc: git@vger•kernel.org, sunshine@sunshineco•com, ps@pks•im,
karthik.188@gmail•com
Subject: Re: [PATCH v4 1/2] repo: factor out field printing to dedicated function
Date: Mon, 17 Nov 2025 10:48:34 -0800 [thread overview]
Message-ID: <xmqqldk4ijgd.fsf@gitster.g> (raw)
In-Reply-To: <20251117151844.14802-2-lucasseikioshiro@gmail.com> (Lucas Seiki Oshiro's message of "Mon, 17 Nov 2025 12:02:51 -0300")
Lucas Seiki Oshiro <lucasseikioshiro@gmail•com> writes:
> Move the field printing in git-repo-info to a new function called
> `print_field`, allowing it to be called by functions other than
> `print_fields`.
Missing:
Also change its use of quote_c_style() helper to output directly to
the standard output stream, instead of taking a result in a strbuf
and then printing it outselves.
The patch text looks great.
> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
> ---
> builtin/repo.c | 34 ++++++++++++++++++----------------
> 1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/builtin/repo.c b/builtin/repo.c
> index 9d4749f79b..f9fb418494 100644
> --- a/builtin/repo.c
> +++ b/builtin/repo.c
> @@ -85,13 +85,29 @@ static get_value_fn *get_value_fn_for_key(const char *key)
> return found ? found->get_value : NULL;
> }
>
> +static void print_field(enum output_format format, const char *key,
> + const char *value)
> +{
> + switch (format) {
> + case FORMAT_KEYVALUE:
> + printf("%s=", key);
> + quote_c_style(value, NULL, stdout, 0);
> + putchar('\n');
> + break;
> + case FORMAT_NUL_TERMINATED:
> + printf("%s\n%s%c", key, value, '\0');
> + break;
> + default:
> + BUG("not a valid output format: %d", format);
> + }
> +}
> +
> static int print_fields(int argc, const char **argv,
> struct repository *repo,
> enum output_format format)
> {
> int ret = 0;
> struct strbuf valbuf = STRBUF_INIT;
> - struct strbuf quotbuf = STRBUF_INIT;
>
> for (int i = 0; i < argc; i++) {
> get_value_fn *get_value;
> @@ -105,25 +121,11 @@ static int print_fields(int argc, const char **argv,
> }
>
> strbuf_reset(&valbuf);
> - strbuf_reset("buf);
> -
> get_value(repo, &valbuf);
> -
> - switch (format) {
> - case FORMAT_KEYVALUE:
> - quote_c_style(valbuf.buf, "buf, NULL, 0);
> - printf("%s=%s\n", key, quotbuf.buf);
> - break;
> - case FORMAT_NUL_TERMINATED:
> - printf("%s\n%s%c", key, valbuf.buf, '\0');
> - break;
> - default:
> - BUG("not a valid output format: %d", format);
> - }
> + print_field(format, key, valbuf.buf);
> }
>
> strbuf_release(&valbuf);
> - strbuf_release("buf);
> return ret;
> }
next prev parent reply other threads:[~2025-11-17 18:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 22:36 [PATCH] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-09-15 23:58 ` Junio C Hamano
2025-09-16 8:06 ` Patrick Steinhardt
2025-09-16 16:19 ` Junio C Hamano
2025-09-17 5:34 ` Patrick Steinhardt
2025-10-26 22:52 ` [PATCH v3 0/2] " Lucas Seiki Oshiro
2025-10-26 22:52 ` [PATCH v3 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-10-26 23:53 ` Eric Sunshine
2025-10-26 23:56 ` Eric Sunshine
2025-10-27 14:56 ` Junio C Hamano
2025-10-27 16:09 ` Eric Sunshine
2025-10-26 22:52 ` [PATCH v3 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-10-27 0:22 ` Eric Sunshine
2025-10-27 0:24 ` Eric Sunshine
2025-11-17 15:02 ` [PATCH v4 0/2] " Lucas Seiki Oshiro
2025-11-17 15:02 ` [PATCH v4 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-11-17 18:48 ` Junio C Hamano [this message]
2025-11-17 15:02 ` [PATCH v4 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-11-17 18:58 ` Junio C Hamano
2025-11-18 20:16 ` Lucas Seiki Oshiro
2025-11-18 21:28 ` Junio C Hamano
2025-11-20 22:50 ` Lucas Seiki Oshiro
2025-11-19 7:32 ` Eric Sunshine
2025-11-19 14:33 ` Junio C Hamano
2025-11-17 18:14 ` [PATCH v4 0/2] " Junio C Hamano
2025-11-18 20:37 ` [PATCH v5 " Lucas Seiki Oshiro
2025-11-18 20:37 ` [PATCH v5 1/2] repo: factor out field printing to dedicated function Lucas Seiki Oshiro
2025-11-18 20:37 ` [PATCH v5 2/2] repo: add --all to git-repo-info Lucas Seiki Oshiro
2025-11-18 21:34 ` [PATCH v5 0/2] " Junio C Hamano
2025-11-19 7:35 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqldk4ijgd.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=karthik.188@gmail$(echo .)com \
--cc=lucasseikioshiro@gmail$(echo .)com \
--cc=ps@pks$(echo .)im \
--cc=sunshine@sunshineco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox