Skip to content

Commit 88d42af

Browse files
peffgitster
authored andcommitted
t1300: test mixed-case variable retrieval
We should be able to ask for a config value both by its canonical all-lowercase name (as git does internally), as well as by random mixed-case (which will be canonicalized by git-config for us). Subsections are a tricky point, though. Since we have both [section "Foo"] and [section.Foo] you might want git-config to canonicalize the subsection or not, depending on which you are expecting. But there's no way to communicate this; git-config sees only the key, and doesn't know which type of section name will be in the config file. So it must leave the subsection intact, and it is up to the caller to provide a canonical version of the subsection if they want to match the latter form. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a953fc commit 88d42af

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/t1300-repo-config.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ EOF
7373

7474
test_expect_success 'non-match result' 'test_cmp expect .git/config'
7575

76+
test_expect_success 'find mixed-case key by canonical name' '
77+
echo Second >expect &&
78+
git config cores.whatever >actual &&
79+
test_cmp expect actual
80+
'
81+
82+
test_expect_success 'find mixed-case key by non-canonical name' '
83+
echo Second >expect &&
84+
git config CoReS.WhAtEvEr >actual &&
85+
test_cmp expect actual
86+
'
87+
88+
test_expect_success 'subsections are not canonicalized by git-config' '
89+
cat >>.git/config <<-\EOF &&
90+
[section.SubSection]
91+
key = one
92+
[section "SubSection"]
93+
key = two
94+
EOF
95+
echo one >expect &&
96+
git config section.subsection.key >actual &&
97+
test_cmp expect actual &&
98+
echo two >expect &&
99+
git config section.SubSection.key >actual &&
100+
test_cmp expect actual
101+
'
102+
76103
cat > .git/config <<\EOF
77104
[alpha]
78105
bar = foo

0 commit comments

Comments
 (0)