Skip to content

Commit 399e27a

Browse files
lucasoshirogitster
authored andcommitted
repo: rename "keyvalue" to "lines"
The output format name "keyvalue" isn't so descriptive. Rename it to "lines", since it describes better the syntax of the output format and it isn't tied to key-value pairs. Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1faf5b0 commit 399e27a

4 files changed

Lines changed: 25 additions & 23 deletions

File tree

Documentation/git-repo.adoc

Lines changed: 11 additions & 10 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) | -z]
11+
git repo info [--format=(lines|nul) | -z] [--all | <key>...]
12+
git repo structure [--format=(table|lines|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=(lines|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).
@@ -30,21 +30,22 @@ requested. The `--all` flag requests the values for all the available keys.
3030
The output format can be chosen through the flag `--format`. Two formats are
3131
supported:
3232
+
33-
`keyvalue`:::
33+
34+
`lines`:::
3435
output key-value pairs one per line using the `=` character as
3536
the delimiter between the key and the value. Values containing "unusual"
3637
characters are quoted as explained for the configuration variable
3738
`core.quotePath` (see linkgit:git-config[1]). This is the default.
3839

3940
`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
4142
between the key and the value and using a NUL character after each value.
4243
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.
4445
+
4546
`-z` is an alias for `--format=nul`.
4647

47-
`structure [--format=(table|keyvalue|nul) | -z]`::
48+
`structure [--format=(table|lines|nul) | -z]`::
4849
Retrieve statistics about the current repository structure. The
4950
following kinds of information are reported:
5051
+
@@ -61,17 +62,17 @@ supported:
6162
change and is not intended for machine parsing. This is the default
6263
format.
6364

64-
`keyvalue`:::
65+
`lines`:::
6566
Each line of output contains a key-value pair for a repository stat.
6667
The '=' character is used to delimit between the key and the value.
6768
Values containing "unusual" characters are quoted as explained for the
6869
configuration variable `core.quotePath` (see linkgit:git-config[1]).
6970

7071
`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
7273
key-value pairs instead of a newline. Also uses a newline character as
7374
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
7576
quoted.
7677
+
7778
`-z` is an alias for `--format=nul`.

builtin/repo.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
#include "utf8.h"
1818

1919
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]",
2222
NULL
2323
};
2424

2525
typedef int get_value_fn(struct repository *repo, struct strbuf *buf);
2626

2727
enum output_format {
2828
FORMAT_TABLE,
29-
FORMAT_KEYVALUE,
29+
FORMAT_LINES,
3030
FORMAT_NUL_TERMINATED,
3131
};
3232

@@ -91,7 +91,7 @@ static void print_field(enum output_format format, const char *key,
9191
const char *value)
9292
{
9393
switch (format) {
94-
case FORMAT_KEYVALUE:
94+
case FORMAT_LINES:
9595
printf("%s=", key);
9696
quote_c_style(value, NULL, stdout, 0);
9797
putchar('\n');
@@ -157,8 +157,8 @@ static int parse_format_cb(const struct option *opt,
157157
*format = FORMAT_NUL_TERMINATED;
158158
else if (!strcmp(arg, "nul"))
159159
*format = FORMAT_NUL_TERMINATED;
160-
else if (!strcmp(arg, "keyvalue"))
161-
*format = FORMAT_KEYVALUE;
160+
else if (!strcmp(arg, "lines"))
161+
*format = FORMAT_LINES;
162162
else if (!strcmp(arg, "table"))
163163
*format = FORMAT_TABLE;
164164
else
@@ -170,7 +170,7 @@ static int parse_format_cb(const struct option *opt,
170170
static int cmd_repo_info(int argc, const char **argv, const char *prefix,
171171
struct repository *repo)
172172
{
173-
enum output_format format = FORMAT_KEYVALUE;
173+
enum output_format format = FORMAT_LINES;
174174
int all_keys = 0;
175175
struct option options[] = {
176176
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,
185185
};
186186

187187
argc = parse_options(argc, argv, prefix, options, repo_usage, 0);
188-
if (format != FORMAT_KEYVALUE && format != FORMAT_NUL_TERMINATED)
188+
189+
if (format != FORMAT_LINES && format != FORMAT_NUL_TERMINATED)
189190
die(_("unsupported output format"));
190191

191192
if (all_keys && argc)
@@ -671,7 +672,7 @@ static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
671672
stats_table_setup_structure(&table, &stats);
672673
stats_table_print_structure(&table);
673674
break;
674-
case FORMAT_KEYVALUE:
675+
case FORMAT_LINES:
675676
structure_keyvalue_print(&stats, '=', '\n');
676677
break;
677678
case FORMAT_NUL_TERMINATED:

t/t1900-repo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_repo_info () {
3434
eval "$init_command $repo_name"
3535
'
3636

37-
test_expect_success "keyvalue: $label" '
37+
test_expect_success "lines: $label" '
3838
echo "$key=$expected_value" > expect &&
3939
git -C "$repo_name" repo info "$key" >actual &&
4040
test_cmp expect actual
@@ -115,7 +115,7 @@ test_expect_success '-z uses nul-terminated format' '
115115

116116
test_expect_success 'git repo info uses the last requested format' '
117117
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 &&
119119
test_cmp expected actual
120120
'
121121

t/t1901-repo-structure.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test_expect_success SHA1 'repository with references and objects' '
113113
)
114114
'
115115

116-
test_expect_success SHA1 'keyvalue and nul format' '
116+
test_expect_success SHA1 'lines and nul format' '
117117
test_when_finished "rm -rf repo" &&
118118
git init repo &&
119119
(
@@ -140,7 +140,7 @@ test_expect_success SHA1 'keyvalue and nul format' '
140140
objects.tags.disk_size=$(object_type_disk_usage tag)
141141
EOF
142142
143-
git repo structure --format=keyvalue >out 2>err &&
143+
git repo structure --format=lines >out 2>err &&
144144
145145
test_cmp expect out &&
146146
test_line_count = 0 err &&

0 commit comments

Comments
 (0)