From 6fd44f55a7594842e70d549853b7f1ac4e27e6ea Mon Sep 17 00:00:00 2001 From: Lucas Seiki Oshiro Date: Thu, 4 Dec 2025 17:10:10 -0300 Subject: [PATCH 1/3] repo: remove blank line from Documentation/git-repo.adoc There was an extra blank line in git-repo-structure documentation, which led to an unwawnted '+' character after generating an HTML or PDF from that page. This can be seen, for example, in Git 2.52.0 online docs [1]. Remove that extra line. [1] https://git-scm.com/docs/git-repo/2.52.0 Signed-off-by: Lucas Seiki Oshiro Signed-off-by: Junio C Hamano --- Documentation/git-repo.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc index 70f0a6d2e4..5d9c7641c2 100644 --- a/Documentation/git-repo.adoc +++ b/Documentation/git-repo.adoc @@ -50,7 +50,6 @@ supported: + * Reference counts categorized by type * Reachable object counts categorized by type - + The output format can be chosen through the flag `--format`. Three formats are supported: From 768cf991ffea54dbcaf63c45750f0e3a26ebdcc6 Mon Sep 17 00:00:00 2001 From: Lucas Seiki Oshiro Date: Thu, 4 Dec 2025 17:10:11 -0300 Subject: [PATCH 2/3] repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis The flag -z is only an alias for --format=null and even though --format and -z can be used together and repeated, only the last one is considered. Replace `[-z]` in the synopsis of git-repo-info by `[--format=... | -z]`, expliciting that the use of one of those flags replace the other. Signed-off-by: Lucas Seiki Oshiro Signed-off-by: Junio C Hamano --- Documentation/git-repo.adoc | 4 ++-- builtin/repo.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc index 5d9c7641c2..f24514deaa 100644 --- a/Documentation/git-repo.adoc +++ b/Documentation/git-repo.adoc @@ -8,7 +8,7 @@ git-repo - Retrieve information about the repository SYNOPSIS -------- [synopsis] -git repo info [--format=(keyvalue|nul)] [-z] [--all | ...] +git repo info [--format=(keyvalue|nul) | -z] [--all | ...] git repo structure [--format=(table|keyvalue|nul)] DESCRIPTION @@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. COMMANDS -------- -`info [--format=(keyvalue|nul)] [-z] [--all | ...]`:: +`info [--format=(keyvalue|nul) | -z] [--all | ...]`:: Retrieve metadata-related information about the current repository. Only the requested data will be returned based on their keys (see "INFO KEYS" section below). diff --git a/builtin/repo.c b/builtin/repo.c index 2a653bd3ea..cc97dd1836 100644 --- a/builtin/repo.c +++ b/builtin/repo.c @@ -15,7 +15,7 @@ #include "utf8.h" static const char *const repo_usage[] = { - "git repo info [--format=(keyvalue|nul)] [-z] [--all | ...]", + "git repo info [--format=(keyvalue|nul) | -z] [--all | ...]", "git repo structure [--format=(table|keyvalue|nul)]", NULL }; From 76c0704bdf6ee8ac0be11830cb6ae8d08cc587a8 Mon Sep 17 00:00:00 2001 From: Lucas Seiki Oshiro Date: Thu, 4 Dec 2025 17:10:12 -0300 Subject: [PATCH 3/3] repo: add -z as an alias for --format=nul to git-repo-structure 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 Signed-off-by: Junio C Hamano --- Documentation/git-repo.adoc | 6 ++++-- builtin/repo.c | 6 +++++- t/t1901-repo-structure.sh | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc index f24514deaa..c4a78277df 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 | ...] -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: + @@ -71,6 +71,8 @@ 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 cc97dd1836..0dd41b1778 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 | ...]", - "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..df7d4ea524 100755 --- a/t/t1901-repo-structure.sh +++ b/t/t1901-repo-structure.sh @@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' ' tr "\n=" "\0\n" expect_nul && git repo structure --format=nul >out 2>err && + test_cmp expect_nul out && + test_line_count = 0 err && + + # "-z", as a synonym to "--format=nul", participates in the + # usual "last one wins" rule. + git repo structure --format=table -z >out 2>err && + test_cmp expect_nul out && test_line_count = 0 err )