Skip to content

Commit 5613c83

Browse files
committed
Merge branch 'tb/config-fixed-value-with-valueless-true' into maint-2.46
"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
2 parents a991fff + 615d2de commit 5613c83

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,7 @@ static int matches(const char *key, const char *value,
29142914
{
29152915
if (strcmp(key, store->key))
29162916
return 0; /* not ours */
2917-
if (store->fixed_value)
2917+
if (store->fixed_value && value)
29182918
return !strcmp(store->fixed_value, value);
29192919
if (!store->value_pattern)
29202920
return 1; /* always matches */

t/t1300-config.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,15 @@ test_expect_success '--get and --get-all with --fixed-value' '
27042704
test_must_fail git config --file=config --get-regexp --fixed-value fixed+ non-existent
27052705
'
27062706

2707+
test_expect_success '--fixed-value with value-less configuration' '
2708+
test_when_finished rm -f config &&
2709+
cat >config <<-\EOF &&
2710+
[section]
2711+
key
2712+
EOF
2713+
git config --file=config --fixed-value section.key value pattern
2714+
'
2715+
27072716
test_expect_success 'includeIf.hasconfig:remote.*.url' '
27082717
git init hasremoteurlTest &&
27092718
test_when_finished "rm -rf hasremoteurlTest" &&

0 commit comments

Comments
 (0)