From: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
To: git@vger•kernel.org
Cc: sunshine@sunshineco•com, ps@pks•im, karthik.188@gmail•com,
gitster@pobox•com,
Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Subject: [PATCH v4 0/2] repo: add --all to git-repo-info
Date: Mon, 17 Nov 2025 12:02:50 -0300 [thread overview]
Message-ID: <20251117151844.14802-1-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250915223618.13093-1-lucasseikioshiro@gmail.com>
Hi!
Sorry for only sending this after some weeks. I've been busy finishing
my master's and I didn't have enough time to send another version. But
here it is.
This fourth version of this patch addresses the issues pointed by Eric
in the v3:
- I dropped the `strbuf quotebuf`, since it can be replaced by
outputting `quote_c_style` directly to `stdout`;
- `print_field` now uses the string `value` instead of the
`strbuf valbuf`;
- The variable `field` in `print_fields` was replaced by a pointer,
since it didn't require to be copied;
- replace the help string by the suggested.
Lucas Seiki Oshiro (2):
repo: factor out field printing to dedicated function
repo: add --all to git-repo-info
Documentation/git-repo.adoc | 6 ++--
builtin/repo.c | 62 +++++++++++++++++++++++++++----------
t/t1900-repo.sh | 21 +++++++++++++
3 files changed, 69 insertions(+), 20 deletions(-)
Range-diff against v3:
1: 0db9aad2bc ! 1: fce09770b8 repo: factor out field printing to dedicated function
@@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)
}
+static void print_field(enum output_format format, const char *key,
-+ struct strbuf *valbuf, struct strbuf *quotbuf)
++ const char *value)
+{
-+ strbuf_reset(quotbuf);
-+
+ switch (format) {
+ case FORMAT_KEYVALUE:
-+ quote_c_style(valbuf->buf, quotbuf, NULL, 0);
-+ printf("%s=%s\n", key, quotbuf->buf);
++ printf("%s=", key);
++ quote_c_style(value, NULL, stdout, 0);
++ putchar('\n');
+ break;
+ case FORMAT_NUL_TERMINATED:
-+ printf("%s\n%s%c", key, valbuf->buf, '\0');
++ printf("%s\n%s%c", key, value, '\0');
+ break;
+ default:
+ BUG("not a valid output format: %d", format);
@@ builtin/repo.c: static get_value_fn *get_value_fn_for_key(const char *key)
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;
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
}
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
- default:
- BUG("not a valid output format: %d", format);
- }
-+ print_field(format, key, &valbuf, "buf);
++ print_field(format, key, valbuf.buf);
}
strbuf_release(&valbuf);
+- strbuf_release("buf);
+ return ret;
+ }
+
2: b6ecdc2c2f ! 2: ccdad86123 repo: add --all to git-repo-info
@@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor
[synopsis]
-git repo info [--format=(keyvalue|nul)] [-z] [<key>...]
+git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
+ git repo structure [--format=(table|keyvalue|nul)]
DESCRIPTION
- -----------
@@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
COMMANDS
@@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN
## builtin/repo.c ##
@@
- #include "shallow.h"
+ #include "utf8.h"
static const char *const repo_usage[] = {
- "git repo info [--format=(keyvalue|nul)] [-z] [<key>...]",
+ "git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
+ "git repo structure [--format=(table|keyvalue|nul)]",
NULL
};
-
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
return ret;
}
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
+ enum output_format format)
+{
+ struct strbuf valbuf = STRBUF_INIT;
-+ struct strbuf quotbuf = STRBUF_INIT;
+
+ for (unsigned long i = 0; i < ARRAY_SIZE(repo_info_fields); i++) {
-+ struct field field = repo_info_fields[i];
++ const struct field *field = &repo_info_fields[i];
+
+ strbuf_reset(&valbuf);
-+ field.get_value(repo, &valbuf);
-+ print_field(format, field.key, &valbuf, "buf);
++ field->get_value(repo, &valbuf);
++ print_field(format, field->key, valbuf.buf);
+ }
+
+ strbuf_release(&valbuf);
-+ strbuf_release("buf);
+}
+
static int parse_format_cb(const struct option *opt,
const char *arg, int unset UNUSED)
{
-@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,
- struct repository *repo)
+@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
+ struct repository *repo)
{
enum output_format format = FORMAT_KEYVALUE;
+ int all_keys = 0;
struct option options[] = {
OPT_CALLBACK_F(0, "format", &format, N_("format"),
N_("output format"),
-@@ builtin/repo.c: static int repo_info(int argc, const char **argv, const char *prefix,
+@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
N_("synonym for --format=nul"),
PARSE_OPT_NONEG | PARSE_OPT_NOARG,
parse_format_cb),
-+ OPT_BOOL(0, "all", &all_keys, N_("return all keys")),
++ OPT_BOOL(0, "all", &all_keys, N_("print all keys/values")),
OPT_END()
};
- argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
+@@ builtin/repo.c: static int cmd_repo_info(int argc, const char **argv, const char *prefix,
+ if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
+ die(_("unsupported output format"));
+ if (all_keys) {
+ if (argc)
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2025-11-17 15:22 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 ` Lucas Seiki Oshiro [this message]
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
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=20251117151844.14802-1-lucasseikioshiro@gmail.com \
--to=lucasseikioshiro@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=karthik.188@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