Merge branch 'cn/config-missing-path' into maint

* cn/config-missing-path:
  config: don't segfault when given --path with a missing value
maint
Junio C Hamano 2012-11-25 18:35:46 -08:00
commit ccf1bb3ab6
2 changed files with 7 additions and 1 deletions

View File

@ -129,7 +129,8 @@ static int show_config(const char *key_, const char *value_, void *cb)
else else
sprintf(value, "%d", v); sprintf(value, "%d", v);
} else if (types == TYPE_PATH) { } 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; must_free_vptr = 1;
} else if (value_) { } else if (value_) {
vptr = value_; vptr = value_;

View File

@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
test_cmp expect result 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 cat > expect << EOF
[quote] [quote]
leading = " test" leading = " test"