repo: rename the output format "keyvalue" to "lines"

Both subcommands in git-repo(1) accept the "keyvalue" format. This format is newline-delimited, where the key is separated from the value with an equals sign. The name of this option is suboptimal though, as it is both too limiting while at the same time not really indicating what it actually does: - There is no mention of the format being newline-delimited, which is the key differentiator to the "nul" format. - Both "nul" and "keyvalue" have a key and a value, so the latter is not exactly giving any hint what makes it so special. - "keyvalue" requires there to be, well, a key and a value, but we want to add additional output that is only going to be newline delimited. Taken together, "keyvalue" is kind of a bad name for this output format. Luckily, the git-repo(1) command is still rather new and marked as experimental, so things aren't cast into stone yet. Rename the format to "lines" instead to better indicate that the major difference is that we'll get newline-delimited output. This new name will also be a better fit for a subsequent extension in git-repo(1). Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lucas Seiki Oshiro committed Feb 13, 2026 at 21:35 UTC ebb667add9b6be123b6eb6f4b9de636c83d6f30c
4 files changed +25 -23
Documentation/git-repo.adoc
+11 -10
@@ -8,8 +8,8 @@ git-repo - Retrieve information about the repository
8 SYNOPSIS
9 --------
10 [synopsis]
11 -git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
12 -git repo structure [--format=(table|keyvalue|nul) | -z]
11 +git repo info [--format=(lines|nul) | -z] [--all | <key>...]
12 +git repo structure [--format=(table|lines|nul) | -z]
13
14 DESCRIPTION
15 -----------
@@ -19,7 +19,7 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
19
20 COMMANDS
21 --------
22 -`info [--format=(keyvalue|nul) | -z] [--all | <key>...]`::
22 +`info [--format=(lines|nul) | -z] [--all | <key>...]`::
23 Retrieve metadata-related information about the current repository. Only
24 the requested data will be returned based on their keys (see "INFO KEYS"
25 section below).
@@ -30,21 +30,22 @@ requested. The `--all` flag requests the values for all the available keys.
30 The output format can be chosen through the flag `--format`. Two formats are
31 supported:
32 +
33 -`keyvalue`:::
33 +
34 +`lines`:::
35 output key-value pairs one per line using the `=` character as
36 the delimiter between the key and the value. Values containing "unusual"
37 characters are quoted as explained for the configuration variable
38 `core.quotePath` (see linkgit:git-config[1]). This is the default.
39
40 `nul`:::
40 - similar to `keyvalue`, but using a newline character as the delimiter
41 + similar to `lines`, but using a newline character as the delimiter
42 between the key and the value and using a NUL character after each value.
43 This format is better suited for being parsed by another applications than
43 - `keyvalue`. Unlike in the `keyvalue` format, the values are never quoted.
44 + `lines`. Unlike in the `lines` format, the values are never quoted.
45 +
46 `-z` is an alias for `--format=nul`.
47
47 -`structure [--format=(table|keyvalue|nul) | -z]`::
48 +`structure [--format=(table|lines|nul) | -z]`::
49 Retrieve statistics about the current repository structure. The
50 following kinds of information are reported:
51 +
@@ -61,17 +62,17 @@ supported:
62 change and is not intended for machine parsing. This is the default
63 format.
64
64 -`keyvalue`:::
65 +`lines`:::
66 Each line of output contains a key-value pair for a repository stat.
67 The '=' character is used to delimit between the key and the value.
68 Values containing "unusual" characters are quoted as explained for the
69 configuration variable `core.quotePath` (see linkgit:git-config[1]).
70
71 `nul`:::
71 - Similar to `keyvalue`, but uses a NUL character to delimit between
72 + Similar to `lines`, but uses a NUL character to delimit between
73 key-value pairs instead of a newline. Also uses a newline character as
74 the delimiter between the key and value instead of '='. Unlike the
74 - `keyvalue` format, values containing "unusual" characters are never
75 + `lines` format, values containing "unusual" characters are never
76 quoted.
77 +
78 `-z` is an alias for `--format=nul`.
builtin/repo.c
+10 -9
@@ -17,8 +17,8 @@
17 #include "utf8.h"
18
19 static const char *const repo_usage[] = {
20 - "git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]",
21 - "git repo structure [--format=(table|keyvalue|nul) | -z]",
20 + "git repo info [--format=(lines|nul) | -z] [--all | <key>...]",
21 + "git repo structure [--format=(table|lines|nul) | -z]",
22 NULL
23 };
24
@@ -26,7 +26,7 @@ typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
26
27 enum output_format {
28 FORMAT_TABLE,
29 - FORMAT_KEYVALUE,
29 + FORMAT_NEWLINE_TERMINATED,
30 FORMAT_NUL_TERMINATED,
31 };
32
@@ -91,7 +91,7 @@ static void print_field(enum output_format format, const char *key,
91 const char *value)
92 {
93 switch (format) {
94 - case FORMAT_KEYVALUE:
94 + case FORMAT_NEWLINE_TERMINATED:
95 printf("%s=", key);
96 quote_c_style(value, NULL, stdout, 0);
97 putchar('\n');
@@ -157,8 +157,8 @@ static int parse_format_cb(const struct option *opt,
157 *format = FORMAT_NUL_TERMINATED;
158 else if (!strcmp(arg, "nul"))
159 *format = FORMAT_NUL_TERMINATED;
160 - else if (!strcmp(arg, "keyvalue"))
161 - *format = FORMAT_KEYVALUE;
160 + else if (!strcmp(arg, "lines"))
161 + *format = FORMAT_NEWLINE_TERMINATED;
162 else if (!strcmp(arg, "table"))
163 *format = FORMAT_TABLE;
164 else
@@ -170,7 +170,7 @@ static int parse_format_cb(const struct option *opt,
170 static int cmd_repo_info(int argc, const char **argv, const char *prefix,
171 struct repository *repo)
172 {
173 - enum output_format format = FORMAT_KEYVALUE;
173 + enum output_format format = FORMAT_NEWLINE_TERMINATED;
174 int all_keys = 0;
175 struct option options[] = {
176 OPT_CALLBACK_F(0, "format", &format, N_("format"),
@@ -185,7 +185,8 @@ static int cmd_repo_info(int argc, const char **argv, const char *prefix,
185 };
186
187 argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
188 - if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
188 +
189 + if (format != FORMAT_NEWLINE_TERMINATED && format != FORMAT_NUL_TERMINATED)
190 die(_("unsupported output format"));
191
192 if (all_keys && argc)
@@ -671,7 +672,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
672 stats_table_setup_structure(&table, &stats);
673 stats_table_print_structure(&table);
674 break;
674 - case FORMAT_KEYVALUE:
675 + case FORMAT_NEWLINE_TERMINATED:
676 structure_keyvalue_print(&stats, '=', '\n');
677 break;
678 case FORMAT_NUL_TERMINATED:
t/t1900-repo.sh
+2 -2
@@ -34,7 +34,7 @@ test_repo_info () {
34 eval "$init_command $repo_name"
35 '
36
37 - test_expect_success "keyvalue: $label" '
37 + test_expect_success "lines: $label" '
38 echo "$key=$expected_value" > expect &&
39 git -C "$repo_name" repo info "$key" >actual &&
40 test_cmp expect actual
@@ -115,7 +115,7 @@ test_expect_success '-z uses nul-terminated format' '
115
116 test_expect_success 'git repo info uses the last requested format' '
117 echo "layout.bare=false" >expected &&
118 - git repo info --format=nul -z --format=keyvalue layout.bare >actual &&
118 + git repo info --format=nul -z --format=lines layout.bare >actual &&
119 test_cmp expected actual
120 '
121
t/t1901-repo-structure.sh
+2 -2
@@ -113,7 +113,7 @@ test_expect_success SHA1 'repository with references and objects' '
113 )
114 '
115
116 -test_expect_success SHA1 'keyvalue and nul format' '
116 +test_expect_success SHA1 'lines and nul format' '
117 test_when_finished "rm -rf repo" &&
118 git init repo &&
119 (
@@ -140,7 +140,7 @@ test_expect_success SHA1 'keyvalue and nul format' '
140 objects.tags.disk_size=$(object_type_disk_usage tag)
141 EOF
142
143 - git repo structure --format=keyvalue >out 2>err &&
143 + git repo structure --format=lines >out 2>err &&
144
145 test_cmp expect out &&
146 test_line_count = 0 err &&