From: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
To: git@vger•kernel.org
Cc: ps@pks•im, karthik.188@gmail•com, gitster@pobox•com,
Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Subject: [GSoC PATCH v3 0/2] repo: add -z and objects.format
Date: Mon, 1 Sep 2025 14:27:30 -0300 [thread overview]
Message-ID: <20250901172732.98845-1-lucasseikioshiro@gmail.com> (raw)
In-Reply-To: <20250820144247.79197-1-lucasseikioshiro@gmail.com>
Hi!
The major change in this v3 is that it's now possible to use --format and -z
together. If the user uses a combination of two or more --format or -z, only
the last one will be considered.
Here's the range-diff versus v2:
1: 3ea40b1572 ! 1: 0323f1fa75 repo: add the flag -z as an alias for --format=nul
@@ Documentation/git-repo.adoc: git-repo - Retrieve information about the repositor
--------
[synopsis]
-git repo info [--format=(keyvalue|nul)] [<key>...]
-+git repo info [--format=(keyvalue|nul) | -z] [<key>...]
++git repo info [--format=(keyvalue|nul)] [-z] [<key>...]
DESCRIPTION
-----------
@@ Documentation/git-repo.adoc: THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHAN
COMMANDS
--------
-`info [--format=(keyvalue|nul)] [<key>...]`::
-+`info [--format=(keyvalue|nul) | -z] [<key>...]`::
++`info [--format=(keyvalue|nul)] [-z] [<key>...]`::
Retrieve metadata-related information about the current repository. Only
the requested data will be returned based on their keys (see "INFO KEYS"
section below).
@@ builtin/repo.c
static const char *const repo_usage[] = {
- "git repo info [--format=(keyvalue|nul)] [<key>...]",
-+ "git repo info [--format=(keyvalue|nul) | -z] [<key>...]",
++ "git repo info [--format=(keyvalue|nul)] [-z] [<key>...]",
NULL
};
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
+ return ret;
+ }
+
++static int parse_format_cb(const struct option *opt,
++ const char *arg, int unset UNUSED) {
++ enum output_format *format = opt->value;
++
++ if (opt->short_name == 'z')
++ *format = FORMAT_NUL_TERMINATED;
++ else if (!strcmp(arg, "nul"))
++ *format = FORMAT_NUL_TERMINATED;
++ else if (!strcmp(arg, "keyvalue"))
++ *format = FORMAT_KEYVALUE;
++ else
++ die(_("invalid format '%s'"), arg);
++
++ return 0;
++}
++
static int repo_info(int argc, const char **argv, const char *prefix,
struct repository *repo)
{
- const char *format_str = "keyvalue";
-+ const char *format_str = NULL;
- enum output_format format;
-+ int format_nul = 0;
+- enum output_format format;
++ enum output_format format = FORMAT_KEYVALUE;
struct option options[] = {
- OPT_STRING(0, "format", &format_str, N_("format"),
- N_("output format")),
-+ OPT_BOOL('z', NULL, &format_nul, N_("alias for --format=nul")),
+- OPT_STRING(0, "format", &format_str, N_("format"),
+- N_("output format")),
++ OPT_CALLBACK_F(0, "format", &format, N_("format"),
++ N_("output format"),
++ PARSE_OPT_NONEG, parse_format_cb),
++ OPT_CALLBACK_F('z', NULL, &format, NULL,
++ N_("synonym for --format=nul"),
++ PARSE_OPT_NONEG|PARSE_OPT_NOARG,
++ parse_format_cb),
OPT_END()
};
@@ builtin/repo.c: static int print_fields(int argc, const char **argv,
- if (!strcmp(format_str, "keyvalue"))
- format = FORMAT_KEYVALUE;
- else if (!strcmp(format_str, "nul"))
-+ die_for_incompatible_opt2(!!format_nul, "-z",
-+ !!format_str, "--format");
-+
-+ format_str = format_str ? format_str : "keyvalue";
-+
-+ if (format_nul || !strcmp(format_str, "nul"))
- format = FORMAT_NUL_TERMINATED;
-+ else if (!strcmp(format_str, "keyvalue"))
-+ format = FORMAT_KEYVALUE;
- else
- die(_("invalid format '%s'"), format_str);
+- format = FORMAT_NUL_TERMINATED;
+- else
+- die(_("invalid format '%s'"), format_str);
+-
+ return print_fields(argc, argv, repo, format);
+ }
## t/t1900-repo.sh ##
@@ t/t1900-repo.sh: test_expect_success 'git-repo-info aborts when requesting an in
+ test_cmp expected actual
+'
+
-+test_expect_success 'git repo info fails when using --format and -z' '
-+ echo "fatal: options ${SQ}-z${SQ} and ${SQ}--format${SQ} cannot be used together" >expected &&
-+ test_must_fail git repo info -z --format=keyvalue 2>actual &&
++test_expect_success 'git repo info uses the last requested format' '
++ echo "layout.bare=false" >expected &&
++ git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
+ test_cmp expected actual
+'
+
2: 1d062e690e = 2: b2b241f401 repo: add the field objects.format
Lucas Seiki Oshiro (2):
repo: add the flag -z as an alias for --format=nul
repo: add the field objects.format
Documentation/git-repo.adoc | 9 ++++++--
builtin/repo.c | 44 +++++++++++++++++++++++++++----------
t/t1900-repo.sh | 18 +++++++++++++++
3 files changed, 57 insertions(+), 14 deletions(-)
--
2.39.5 (Apple Git-154)
next prev parent reply other threads:[~2025-09-01 17:27 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 14:42 [GSoC PATCH 0/2] repo: add -z and objects.format Lucas Seiki Oshiro
2025-08-20 14:42 ` [GSoC PATCH 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-08-21 10:12 ` Karthik Nayak
2025-08-21 16:09 ` Junio C Hamano
2025-08-21 16:52 ` Karthik Nayak
2025-08-21 10:29 ` Patrick Steinhardt
2025-08-21 13:29 ` Lucas Seiki Oshiro
2025-08-21 17:28 ` Junio C Hamano
2025-08-21 20:57 ` Lucas Seiki Oshiro
2025-08-21 21:50 ` Junio C Hamano
2025-08-21 18:23 ` Jean-Noël AVILA
2025-08-21 19:52 ` Junio C Hamano
2025-08-20 14:42 ` [GSoC PATCH 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-08-21 10:29 ` Patrick Steinhardt
2025-08-21 19:44 ` Junio C Hamano
2025-08-26 14:51 ` Lucas Seiki Oshiro
2025-08-21 10:14 ` [GSoC PATCH 0/2] repo: add -z and objects.format Karthik Nayak
2025-08-21 16:12 ` Junio C Hamano
2025-08-21 10:29 ` Patrick Steinhardt
2025-08-21 13:23 ` Lucas Seiki Oshiro
2025-08-21 14:55 ` Patrick Steinhardt
2025-08-21 17:28 ` Junio C Hamano
2025-08-26 18:13 ` Lucas Seiki Oshiro
2025-08-26 18:32 ` [GSoC PATCH v2 " Lucas Seiki Oshiro
2025-08-26 18:32 ` [GSoC PATCH v2 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-08-28 23:08 ` Junio C Hamano
2025-09-01 13:50 ` Lucas Seiki Oshiro
2025-08-26 18:32 ` [GSoC PATCH v2 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-09-01 17:27 ` Lucas Seiki Oshiro [this message]
2025-09-01 17:27 ` [GSoC PATCH v3 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-09-02 16:21 ` Junio C Hamano
2025-09-02 21:51 ` Lucas Seiki Oshiro
2025-09-01 17:27 ` [GSoC PATCH v3 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-09-04 13:40 ` [GSoC PATCH v4 0/2] repo: add -z and objects.format Lucas Seiki Oshiro
2025-09-04 13:40 ` [GSoC PATCH v4 1/2] repo: add the flag -z as an alias for --format=nul Lucas Seiki Oshiro
2025-09-04 13:40 ` [GSoC PATCH v4 2/2] repo: add the field objects.format Lucas Seiki Oshiro
2025-09-04 18:40 ` [GSoC PATCH v4 0/2] repo: add -z and objects.format Junio C Hamano
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=20250901172732.98845-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 \
/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