summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-11-20 10:40:46 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-11-20 10:40:46 -0800
commit0f76f976762d6a15a4af75db56208c8065492020 (patch)
treee77862b1d6d5f971b9bf9230117e066fd0618298
parentMerge branch 'jl/submodule-rm' (diff)
parentconfig: don't segfault when given --path with a missing value (diff)
downloadtgif-0f76f976762d6a15a4af75db56208c8065492020.tar.xz
Merge branch 'cn/config-missing-path'
"git config --path $key" segfaulted on "[section] key" (a boolean "true" spelled without "=", not "[section] key = true"). * cn/config-missing-path: config: don't segfault when given --path with a missing value
-rw-r--r--builtin/config.c3
-rwxr-xr-xt/t1300-repo-config.sh5
2 files changed, 7 insertions, 1 deletions
diff --git a/builtin/config.c b/builtin/config.c
index e1c33e0691..505bbc7ddd 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -129,7 +129,8 @@ static int show_config(const char *key_, const char *value_, void *cb)
else
sprintf(value, "%d", v);
} else if (types == TYPE_PATH) {
- git_config_pathname(&vptr, key_, value_);
+ if (git_config_pathname(&vptr, key_, value_) < 0)
+ return -1;
must_free_vptr = 1;
} else if (value_) {
vptr = value_;
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index e127f35db9..7c4c372e37 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
test_cmp expect result
'
+test_expect_success 'get --path barfs on boolean variable' '
+ echo "[path]bool" >.git/config &&
+ test_must_fail git config --get --path path.bool
+'
+
cat > expect << EOF
[quote]
leading = " test"