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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 12, 2011 at 14:30 UTC 88d42af893ba2a5cff01506e623f3543ef78f9ed
1 file changed +27
t/t1300-repo-config.sh
+27
@@ -73,6 +73,33 @@ EOF
73
74 test_expect_success 'non-match result' 'test_cmp expect .git/config'
75
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 +
103 cat > .git/config <<\EOF
104 [alpha]
105 bar = foo