summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c2
-rwxr-xr-xt/t1300-repo-config.sh14
2 files changed, 15 insertions, 1 deletions
diff --git a/config.c b/config.c
index b95ac3a9cd..8570eec51d 100644
--- a/config.c
+++ b/config.c
@@ -161,7 +161,7 @@ void git_config_push_parameter(const char *text)
{
struct strbuf env = STRBUF_INIT;
const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
- if (old) {
+ if (old && *old) {
strbuf_addstr(&env, old);
strbuf_addch(&env, ' ');
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 52678e7d0a..c967740304 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1083,6 +1083,20 @@ test_expect_success 'git -c complains about empty key and value' '
test_must_fail git -c "" rev-parse
'
+test_expect_success 'multiple git -c appends config' '
+ test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
+ cat >expect <<-\EOF &&
+ x.one 1
+ x.two 2
+ EOF
+ git -c x.one=1 x >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git -c is not confused by empty environment' '
+ GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
+'
+
test_expect_success 'git config --edit works' '
git config -f tmp test.value no &&
echo test.value=yes >expect &&