From: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
To: git@vger•kernel.org
Cc: jltobler@gmail•com, Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
Subject: [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure
Date: Sun, 30 Nov 2025 16:59:55 -0300 [thread overview]
Message-ID: <20251130203456.28437-1-lucasseikioshiro@gmail.com> (raw)
Other Git commands that have nul-terminated output, such as git-config,
git-status, git-ls-files, and git-repo-info have a flag `-z` for using
the null character as the record separator.
Add the `-z` flag to git-repo-structure as an alias for `--format=nul`,
making it consistent with the behavior of the other commands.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail•com>
---
Hello, again!
Since git-repo-info and git-repo-structure share the same format parser, this
could be done by only copying the OPT_CALLBACK_F from repo_info.
I'm cc'ing Justin here, as he was the author of git-repo-structure.
This patch is based on top of master b31ab939fe (The fourth batch, 2025-11-26)
with lo/repo-info-all merged.
Documentation/git-repo.adoc | 5 +++--
builtin/repo.c | 6 +++++-
t/t1901-repo-structure.sh | 6 ++++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 70f0a6d2e4..8820954f7e 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[synopsis]
git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
-git repo structure [--format=(table|keyvalue|nul)]
+git repo structure [--format=(table|keyvalue|nul)] [-z]
DESCRIPTION
-----------
@@ -44,7 +44,7 @@ supported:
+
`-z` is an alias for `--format=nul`.
-`structure [--format=(table|keyvalue|nul)]`::
+`structure [--format=(table|keyvalue|nul)] [-z]`::
Retrieve statistics about the current repository structure. The
following kinds of information are reported:
+
@@ -72,6 +72,7 @@ supported:
the delimiter between the key and value instead of '='. Unlike the
`keyvalue` format, values containing "unusual" characters are never
quoted.
+`-z` is an alias for `--format=nul`.
INFO KEYS
---------
diff --git a/builtin/repo.c b/builtin/repo.c
index 2a653bd3ea..1c06207a39 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -16,7 +16,7 @@
static const char *const repo_usage[] = {
"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
- "git repo structure [--format=(table|keyvalue|nul)]",
+ "git repo structure [--format=(table|keyvalue|nul)] [-z]",
NULL
};
@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
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_BOOL(0, "progress", &show_progress, N_("show progress")),
OPT_END()
};
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index 36a71a144e..5a50acf345 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -101,6 +101,12 @@ test_expect_success 'keyvalue and nul format' '
tr "\n=" "\0\n" <expect >expect_nul &&
git repo structure --format=nul >out 2>err &&
+ test_cmp expect_nul out &&
+ test_line_count = 0 err &&
+
+ # Check -z
+ git repo structure --format=nul >out 2>err &&
+
test_cmp expect_nul out &&
test_line_count = 0 err
)
--
2.50.1 (Apple Git-155)
next reply other threads:[~2025-11-30 20:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-30 19:59 Lucas Seiki Oshiro [this message]
2025-12-01 2:21 ` [PATCH] repo: add -z as an alias for --format=nul to git-repo-structure Junio C Hamano
2025-12-01 8:28 ` Patrick Steinhardt
2025-12-01 14:34 ` Lucas Seiki Oshiro
2025-12-02 3:45 ` Junio C Hamano
2025-12-02 22:05 ` Lucas Seiki Oshiro
2025-12-01 15:11 ` Justin Tobler
2025-12-02 0:29 ` Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 0/3] " Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 1/3] repo: remove blank line from Documentation/git-repo.adoc Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis Lucas Seiki Oshiro
2025-12-04 20:10 ` [PATCH v2 3/3] repo: add -z as an alias for --format=nul to git-repo-structure Lucas Seiki Oshiro
2025-12-11 5:23 ` Junio C Hamano
2025-12-18 23:02 ` Lucas Seiki Oshiro
2025-12-05 11:09 ` [PATCH v2 0/3] " Patrick Steinhardt
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=20251130203456.28437-1-lucasseikioshiro@gmail.com \
--to=lucasseikioshiro@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=jltobler@gmail$(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