Re: [GSoC PATCH v8 5/5] repo: add the --format flag
From: Patrick Steinhardt <hidden>
Date: 2025-08-07 05:21:02
On Wed, Aug 06, 2025 at 04:55:37PM -0300, Lucas Seiki Oshiro wrote:
quoted hunk ↗ jump to hunk
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc index 1ae9c09fac..2b63954098 100644 --- a/Documentation/git-repo.adoc +++ b/Documentation/git-repo.adoc diff --git a/builtin/repo.c b/builtin/repo.c index 312fd08c34..37b5726816 100644 --- a/builtin/repo.c +++ b/builtin/repo.c@@ -101,8 +108,18 @@ static int print_fields(int argc, const char **argv, struct repository *repo) } get_value(repo, &valbuf); - quote_c_style(valbuf.buf, "buf, NULL, 0); - printf("%s=%s\n", key, quotbuf.buf); + + 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("%d: not a valid output format", format);
Nit: we typically say it the other way round.
BUG("not a valid output format: %d", format);
Doesn't matter too much though as ideally this message shouldn't ever be
seen by any user out there.
Other than my two nits the series looks good to me, thanks! I don't
terribly mind whether or not those nits are addressed.
Patrick