Code

Sync with 1.7.9.5
[git.git] / t / t1300-repo-config.sh
index 0690e0edf4e758200d4febb1c7837b5c7059add6..36e227b3bb25cb17dabc5e205e63056e7fd0b370 100755 (executable)
@@ -451,13 +451,21 @@ test_expect_success 'refer config from subdirectory' '
        mkdir x &&
        (
                cd x &&
-               echo strasse >expect
+               echo strasse >expect &&
                git config --get --file ../other-config ein.bahn >actual &&
                test_cmp expect actual
        )
 
 '
 
+test_expect_success 'refer config from subdirectory via GIT_CONFIG' '
+       (
+               cd x &&
+               GIT_CONFIG=../other-config git config --get ein.bahn >actual &&
+               test_cmp expect actual
+       )
+'
+
 cat > expect << EOF
 [ein]
        bahn = strasse
@@ -960,4 +968,52 @@ test_expect_success 'git -c complains about empty key and value' '
        test_must_fail git -c "" rev-parse
 '
 
+test_expect_success 'git config --edit works' '
+       git config -f tmp test.value no &&
+       echo test.value=yes >expect &&
+       GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
+       git config -f tmp --list >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'git config --edit respects core.editor' '
+       git config -f tmp test.value no &&
+       echo test.value=yes >expect &&
+       test_config core.editor "echo [test]value=yes >" &&
+       git config -f tmp --edit &&
+       git config -f tmp --list >actual &&
+       test_cmp expect actual
+'
+
+# malformed configuration files
+test_expect_success 'barf on syntax error' '
+       cat >.git/config <<-\EOF &&
+       # broken section line
+       [section]
+       key garbage
+       EOF
+       test_must_fail git config --get section.key >actual 2>error &&
+       grep " line 3 " error
+'
+
+test_expect_success 'barf on incomplete section header' '
+       cat >.git/config <<-\EOF &&
+       # broken section line
+       [section
+       key = value
+       EOF
+       test_must_fail git config --get section.key >actual 2>error &&
+       grep " line 2 " error
+'
+
+test_expect_success 'barf on incomplete string' '
+       cat >.git/config <<-\EOF &&
+       # broken section line
+       [section]
+       key = "value string
+       EOF
+       test_must_fail git config --get section.key >actual 2>error &&
+       grep " line 3 " error
+'
+
 test_done