Skip to content

Commit acb7014

Browse files
author
Junio C Hamano
committed
repo-config: fix printing of bool
When a bool variable appears without any value, it means true. However, replacing the NULL value with an empty string, an earlier commit f067a13 broke show-config. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ec2f6b commit acb7014

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

repo-config.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,25 @@ static int show_config(const char* key_, const char* value_)
2929
const char *vptr = value;
3030
int dup_error = 0;
3131

32-
if (value_ == NULL)
33-
value_ = "";
34-
3532
if (!use_key_regexp && strcmp(key_, key))
3633
return 0;
3734
if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
3835
return 0;
3936
if (regexp != NULL &&
4037
(do_not_match ^
41-
regexec(regexp, value_, 0, NULL, 0)))
38+
regexec(regexp, (value_?value_:""), 0, NULL, 0)))
4239
return 0;
4340

4441
if (show_keys)
4542
printf("%s ", key_);
4643
if (seen && !do_all)
4744
dup_error = 1;
4845
if (type == T_INT)
49-
sprintf(value, "%d", git_config_int(key_, value_));
46+
sprintf(value, "%d", git_config_int(key_, value_?value_:""));
5047
else if (type == T_BOOL)
5148
vptr = git_config_bool(key_, value_) ? "true" : "false";
5249
else
53-
vptr = value_;
50+
vptr = value_?value_:"";
5451
seen++;
5552
if (dup_error) {
5653
error("More than one value for the key %s: %s",

0 commit comments

Comments
 (0)