Merge branch 'mm/maint-config-explicit-bool-display' into maint
* mm/maint-config-explicit-bool-display: config: display key_delim for config --bool --get-regexp
This commit is contained in:
commit
634b29d270
@ -99,6 +99,7 @@ static int show_config(const char *key_, const char *value_, void *cb)
|
|||||||
const char *vptr = value;
|
const char *vptr = value;
|
||||||
int must_free_vptr = 0;
|
int must_free_vptr = 0;
|
||||||
int dup_error = 0;
|
int dup_error = 0;
|
||||||
|
int must_print_delim = 0;
|
||||||
|
|
||||||
if (!use_key_regexp && strcmp(key_, key))
|
if (!use_key_regexp && strcmp(key_, key))
|
||||||
return 0;
|
return 0;
|
||||||
@ -109,10 +110,8 @@ static int show_config(const char *key_, const char *value_, void *cb)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (show_keys) {
|
if (show_keys) {
|
||||||
if (value_)
|
printf("%s", key_);
|
||||||
printf("%s%c", key_, key_delim);
|
must_print_delim = 1;
|
||||||
else
|
|
||||||
printf("%s", key_);
|
|
||||||
}
|
}
|
||||||
if (seen && !do_all)
|
if (seen && !do_all)
|
||||||
dup_error = 1;
|
dup_error = 1;
|
||||||
@ -130,16 +129,23 @@ static int show_config(const char *key_, const char *value_, void *cb)
|
|||||||
} else if (types == TYPE_PATH) {
|
} else if (types == TYPE_PATH) {
|
||||||
git_config_pathname(&vptr, key_, value_);
|
git_config_pathname(&vptr, key_, value_);
|
||||||
must_free_vptr = 1;
|
must_free_vptr = 1;
|
||||||
|
} else if (value_) {
|
||||||
|
vptr = value_;
|
||||||
|
} else {
|
||||||
|
/* Just show the key name */
|
||||||
|
vptr = "";
|
||||||
|
must_print_delim = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
vptr = value_?value_:"";
|
|
||||||
seen++;
|
seen++;
|
||||||
if (dup_error) {
|
if (dup_error) {
|
||||||
error("More than one value for the key %s: %s",
|
error("More than one value for the key %s: %s",
|
||||||
key_, vptr);
|
key_, vptr);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
|
if (must_print_delim)
|
||||||
|
printf("%c", key_delim);
|
||||||
printf("%s%c", vptr, term);
|
printf("%s%c", vptr, term);
|
||||||
|
}
|
||||||
if (must_free_vptr)
|
if (must_free_vptr)
|
||||||
/* If vptr must be freed, it's a pointer to a
|
/* If vptr must be freed, it's a pointer to a
|
||||||
* dynamically allocated buffer, it's safe to cast to
|
* dynamically allocated buffer, it's safe to cast to
|
||||||
|
@ -333,6 +333,12 @@ test_expect_success 'get-regexp variable with no value' \
|
|||||||
'git config --get-regexp novalue > output &&
|
'git config --get-regexp novalue > output &&
|
||||||
cmp output expect'
|
cmp output expect'
|
||||||
|
|
||||||
|
echo 'novalue.variable true' > expect
|
||||||
|
|
||||||
|
test_expect_success 'get-regexp --bool variable with no value' \
|
||||||
|
'git config --bool --get-regexp novalue > output &&
|
||||||
|
cmp output expect'
|
||||||
|
|
||||||
echo 'emptyvalue.variable ' > expect
|
echo 'emptyvalue.variable ' > expect
|
||||||
|
|
||||||
test_expect_success 'get-regexp variable with empty value' \
|
test_expect_success 'get-regexp variable with empty value' \
|
||||||
|
Loading…
Reference in New Issue
Block a user