Skip to content

Commit b69ba46

Browse files
flichtenheldgitster
authored andcommitted
config: Change output of --get-regexp for valueless keys
Print no space after the name of a key without value. Otherwise keys without values are printed exactly the same as keys with empty values. Signed-off-by: Frank Lichtenheld <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e373bb7 commit b69ba46

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

builtin-config.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ static int show_config(const char* key_, const char* value_)
3838
regexec(regexp, (value_?value_:""), 0, NULL, 0)))
3939
return 0;
4040

41-
if (show_keys)
42-
printf("%s ", key_);
41+
if (show_keys) {
42+
if (value_)
43+
printf("%s ", key_);
44+
else
45+
printf("%s", key_);
46+
}
4347
if (seen && !do_all)
4448
dup_error = 1;
4549
if (type == T_INT)

t/t1300-repo-config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ EOF
283283
test_expect_success 'get variable with no value' \
284284
'git-config --get novalue.variable ^$'
285285

286+
echo novalue.variable > expect
287+
288+
test_expect_success 'get-regexp variable with no value' \
289+
'git-config --get-regexp novalue > output &&
290+
cmp output expect'
291+
286292
git-config > output 2>&1
287293

288294
test_expect_success 'no arguments, but no crash' \

0 commit comments

Comments
 (0)