Merge branch 'tb/config-fixed-value-with-valueless-true'
"git config --value=foo --fixed-value section.key newvalue" barfed when the existing value in the configuration file used the valueless true syntax, which has been corrected. * tb/config-fixed-value-with-valueless-true: config.c: avoid segfault with --fixed-value and valueless config
This commit is contained in:
2
config.c
2
config.c
@ -2914,7 +2914,7 @@ static int matches(const char *key, const char *value,
|
|||||||
{
|
{
|
||||||
if (strcmp(key, store->key))
|
if (strcmp(key, store->key))
|
||||||
return 0; /* not ours */
|
return 0; /* not ours */
|
||||||
if (store->fixed_value)
|
if (store->fixed_value && value)
|
||||||
return !strcmp(store->fixed_value, value);
|
return !strcmp(store->fixed_value, value);
|
||||||
if (!store->value_pattern)
|
if (!store->value_pattern)
|
||||||
return 1; /* always matches */
|
return 1; /* always matches */
|
||||||
|
@ -2704,6 +2704,15 @@ test_expect_success '--get and --get-all with --fixed-value' '
|
|||||||
test_must_fail git config --file=config --get-regexp --fixed-value fixed+ non-existent
|
test_must_fail git config --file=config --get-regexp --fixed-value fixed+ non-existent
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--fixed-value with value-less configuration' '
|
||||||
|
test_when_finished rm -f config &&
|
||||||
|
cat >config <<-\EOF &&
|
||||||
|
[section]
|
||||||
|
key
|
||||||
|
EOF
|
||||||
|
git config --file=config --fixed-value section.key value pattern
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'includeIf.hasconfig:remote.*.url' '
|
test_expect_success 'includeIf.hasconfig:remote.*.url' '
|
||||||
git init hasremoteurlTest &&
|
git init hasremoteurlTest &&
|
||||||
test_when_finished "rm -rf hasremoteurlTest" &&
|
test_when_finished "rm -rf hasremoteurlTest" &&
|
||||||
|
Reference in New Issue
Block a user