Skip to content

Commit 76c0704

Browse files
lucasoshirogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 768cf99 commit 76c0704

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Documentation/git-repo.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[synopsis]
1111
git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
12-
git repo structure [--format=(table|keyvalue|nul)]
12+
git repo structure [--format=(table|keyvalue|nul) | -z]
1313

1414
DESCRIPTION
1515
-----------
@@ -44,7 +44,7 @@ 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
+
@@ -71,6 +71,8 @@ supported:
7171
the delimiter between the key and value instead of '='. Unlike the
7272
`keyvalue` format, values containing "unusual" characters are never
7373
quoted.
74+
+
75+
`-z` is an alias for `--format=nul`.
7476

7577
INFO KEYS
7678
---------

builtin/repo.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
static const char *const repo_usage[] = {
1818
"git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
19-
"git repo structure [--format=(table|keyvalue|nul)]",
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)