Skip to content

Commit affdbe4

Browse files
committed
Merge branch 'lo/repo-struct-z'
"git repo struct" learned to take "-z" as a synonym to "--format=nul". * lo/repo-struct-z: repo: add -z as an alias for --format=nul to git-repo-structure repo: use [--format=... | -z] instead of [-z] in git-repo-info synopsis repo: remove blank line from Documentation/git-repo.adoc
2 parents 2378ebc + 76c0704 commit affdbe4

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Documentation/git-repo.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
88
SYNOPSIS
99
--------
1010
[synopsis]
11-
git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]
12-
git repo structure [--format=(table|keyvalue|nul)]
11+
git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
12+
git repo structure [--format=(table|keyvalue|nul) | -z]
1313

1414
DESCRIPTION
1515
-----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
1919

2020
COMMANDS
2121
--------
22-
`info [--format=(keyvalue|nul)] [-z] [--all | <key>...]`::
22+
`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
2323
Retrieve metadata-related information about the current repository. Only
2424
the requested data will be returned based on their keys (see "INFO KEYS"
2525
section below).
@@ -44,13 +44,12 @@ supported:
4444
+
4545
`-z` is an alias for `--format=nul`.
4646

47-
`structure [--format=(table|keyvalue|nul)]`::
47+
`structure [--format=(table|keyvalue|nul) | -z]`::
4848
Retrieve statistics about the current repository structure. The
4949
following kinds of information are reported:
5050
+
5151
* Reference counts categorized by type
5252
* Reachable object counts categorized by type
53-
5453
+
5554
The output format can be chosen through the flag `--format`. Three formats are
5655
supported:
@@ -72,6 +71,8 @@ supported:
7271
the delimiter between the key and value instead of '='. Unlike the
7372
`keyvalue` format, values containing "unusual" characters are never
7473
quoted.
74+
+
75+
`-z` is an alias for `--format=nul`.
7576

7677
INFO KEYS
7778
---------

builtin/repo.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include "utf8.h"
1616

1717
static const char *const repo_usage[] = {
18-
"git repo info [--format=(keyvalue|nul)] [-z] [--all | <key>...]",
19-
"git repo structure [--format=(table|keyvalue|nul)]",
18+
"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
19+
"git repo structure [--format=(table|keyvalue|nul) | -z]",
2020
NULL
2121
};
2222

@@ -529,6 +529,10 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
529529
OPT_CALLBACK_F(0, "format", &format, N_("format"),
530530
N_("output format"),
531531
PARSE_OPT_NONEG, parse_format_cb),
532+
OPT_CALLBACK_F('z', NULL, &format, NULL,
533+
N_("synonym for --format=nul"),
534+
PARSE_OPT_NONEG | PARSE_OPT_NOARG,
535+
parse_format_cb),
532536
OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
533537
OPT_END()
534538
};

t/t1901-repo-structure.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ test_expect_success 'keyvalue and nul format' '
101101
tr "\n=" "\0\n" <expect >expect_nul &&
102102
git repo structure --format=nul >out 2>err &&
103103
104+
test_cmp expect_nul out &&
105+
test_line_count = 0 err &&
106+
107+
# "-z", as a synonym to "--format=nul", participates in the
108+
# usual "last one wins" rule.
109+
git repo structure --format=table -z >out 2>err &&
110+
104111
test_cmp expect_nul out &&
105112
test_line_count = 0 err
106113
)

0 commit comments

Comments
 (0)