3 test_description
='Test read_early_config()'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'read early config' '
9 test_config early.config correct &&
10 test-tool config read_early_config early.config >output &&
11 test correct = "$(cat output)"
14 test_expect_success
'in a sub-directory' '
15 test_config early.config sub &&
19 test-tool config read_early_config early.config
21 test sub = "$(cat output)"
24 test_expect_success
'ceiling' '
25 test_config early.config ceiling &&
28 GIT_CEILING_DIRECTORIES="$PWD" &&
29 export GIT_CEILING_DIRECTORIES &&
31 test-tool config read_early_config early.config
33 test_must_be_empty output
36 test_expect_success
'ceiling #2' '
38 git config -f xdg/git/config early.config xdg &&
39 test_config early.config ceiling &&
42 XDG_CONFIG_HOME="$PWD"/xdg &&
43 GIT_CEILING_DIRECTORIES="$PWD" &&
44 export GIT_CEILING_DIRECTORIES XDG_CONFIG_HOME &&
46 test-tool config read_early_config early.config
48 test xdg = "$(cat output)"
51 cmdline_config
="'test.source=cmdline'"
52 test_expect_success
'read config file in right order' '
53 echo "[test]source = home" >>.gitconfig &&
57 echo "[test]source = repo" >>.git/config &&
58 GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config \
59 read_early_config test.source >actual &&
60 cat >expected <<-\EOF &&
65 test_cmp expected actual
74 echo "$*" >.git
/config
&&
75 test-tool config read_early_config early.config
79 test_expect_success
'ignore .git/ with incompatible repository version' '
80 test_with_config "[core]repositoryformatversion = 999999" 2>err &&
81 test_grep "warning:.* Expected git repo version <= [1-9]" err
84 test_expect_failure
'ignore .git/ with invalid repository version' '
85 test_with_config "[core]repositoryformatversion = invalid"
89 test_expect_failure
'ignore .git/ with invalid config' '
93 test_expect_success
'early config and onbranch' '
94 echo "[broken" >broken &&
95 test_with_config "[includeif \"onbranch:topic\"]path=../broken"
98 test_expect_success
'onbranch config outside of git repo' '
99 test_config_global includeIf.onbranch:topic.path non-existent &&