Skip to content

Commit ccf1bb3

Browse files
committed
Merge branch 'cn/config-missing-path' into maint
* cn/config-missing-path: config: don't segfault when given --path with a missing value
2 parents 326922f + 962c38e commit ccf1bb3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ static int show_config(const char *key_, const char *value_, void *cb)
129129
else
130130
sprintf(value, "%d", v);
131131
} else if (types == TYPE_PATH) {
132-
git_config_pathname(&vptr, key_, value_);
132+
if (git_config_pathname(&vptr, key_, value_) < 0)
133+
return -1;
133134
must_free_vptr = 1;
134135
} else if (value_) {
135136
vptr = value_;

t/t1300-repo-config.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
803803
test_cmp expect result
804804
'
805805

806+
test_expect_success 'get --path barfs on boolean variable' '
807+
echo "[path]bool" >.git/config &&
808+
test_must_fail git config --get --path path.bool
809+
'
810+
806811
cat > expect << EOF
807812
[quote]
808813
leading = " test"

0 commit comments

Comments
 (0)