write_name_quoted(): make one of the path a counted string.
[git/jnareb-git.git] / t / t1300-repo-config.sh
blob5e994ff00982454d49ae8e218aa0073baadbbe66
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test git-repo-config in different settings'
8 . ./test-lib.sh
10 test -f .git/config && rm .git/config
12 git-repo-config core.penguin "little blue"
14 cat > expect << EOF
16 # This is the config file
19 [core]
20 penguin = little blue
21 EOF
23 test_expect_success 'initial' 'cmp .git/config expect'
25 git-repo-config Core.Movie BadPhysics
27 cat > expect << EOF
29 # This is the config file
32 [core]
33 penguin = little blue
34 Movie = BadPhysics
35 EOF
37 test_expect_success 'mixed case' 'cmp .git/config expect'
39 git-repo-config Cores.WhatEver Second
41 cat > expect << EOF
43 # This is the config file
46 [core]
47 penguin = little blue
48 Movie = BadPhysics
49 [Cores]
50 WhatEver = Second
51 EOF
53 test_expect_success 'similar section' 'cmp .git/config expect'
55 git-repo-config CORE.UPPERCASE true
57 cat > expect << EOF
59 # This is the config file
62 [core]
63 penguin = little blue
64 Movie = BadPhysics
65 UPPERCASE = true
66 [Cores]
67 WhatEver = Second
68 EOF
70 test_expect_success 'similar section' 'cmp .git/config expect'
72 test_expect_success 'replace with non-match' \
73 'git-repo-config core.penguin kingpin !blue'
75 test_expect_success 'replace with non-match (actually matching)' \
76 'git-repo-config core.penguin "very blue" !kingpin'
78 cat > expect << EOF
80 # This is the config file
83 [core]
84 penguin = very blue
85 Movie = BadPhysics
86 UPPERCASE = true
87 penguin = kingpin
88 [Cores]
89 WhatEver = Second
90 EOF
92 test_expect_success 'non-match result' 'cmp .git/config expect'
94 cat > .git/config << EOF
95 [beta] ; silly comment # another comment
96 noIndent= sillyValue ; 'nother silly comment
98 # empty line
99 ; comment
100 haha ="beta" # last silly comment
101 haha = hello
102 haha = bello
103 [nextSection] noNewline = ouch
106 cp .git/config .git/config2
108 test_expect_success 'multiple unset' \
109 'git-repo-config --unset-all beta.haha'
111 cat > expect << EOF
112 [beta] ; silly comment # another comment
113 noIndent= sillyValue ; 'nother silly comment
115 # empty line
116 ; comment
117 [nextSection] noNewline = ouch
120 test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
122 mv .git/config2 .git/config
124 test_expect_success '--replace-all' \
125 'git-repo-config --replace-all beta.haha gamma'
127 cat > expect << EOF
128 [beta] ; silly comment # another comment
129 noIndent= sillyValue ; 'nother silly comment
131 # empty line
132 ; comment
133 haha = gamma
134 [nextSection] noNewline = ouch
137 test_expect_success 'all replaced' 'cmp .git/config expect'
139 git-repo-config beta.haha alpha
141 cat > expect << EOF
142 [beta] ; silly comment # another comment
143 noIndent= sillyValue ; 'nother silly comment
145 # empty line
146 ; comment
147 haha = alpha
148 [nextSection] noNewline = ouch
151 test_expect_success 'really mean test' 'cmp .git/config expect'
153 git-repo-config nextsection.nonewline wow
155 cat > expect << EOF
156 [beta] ; silly comment # another comment
157 noIndent= sillyValue ; 'nother silly comment
159 # empty line
160 ; comment
161 haha = alpha
162 [nextSection]
163 nonewline = wow
166 test_expect_success 'really really mean test' 'cmp .git/config expect'
168 test_expect_success 'get value' 'test alpha = $(git-repo-config beta.haha)'
169 git-repo-config --unset beta.haha
171 cat > expect << EOF
172 [beta] ; silly comment # another comment
173 noIndent= sillyValue ; 'nother silly comment
175 # empty line
176 ; comment
177 [nextSection]
178 nonewline = wow
181 test_expect_success 'unset' 'cmp .git/config expect'
183 git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
185 cat > expect << EOF
186 [beta] ; silly comment # another comment
187 noIndent= sillyValue ; 'nother silly comment
189 # empty line
190 ; comment
191 [nextSection]
192 nonewline = wow
193 NoNewLine = wow2 for me
196 test_expect_success 'multivar' 'cmp .git/config expect'
198 test_expect_success 'non-match' \
199 'git-repo-config --get nextsection.nonewline !for'
201 test_expect_success 'non-match value' \
202 'test wow = $(git-repo-config --get nextsection.nonewline !for)'
204 test_expect_failure 'ambiguous get' \
205 'git-repo-config --get nextsection.nonewline'
207 test_expect_success 'get multivar' \
208 'git-repo-config --get-all nextsection.nonewline'
210 git-repo-config nextsection.nonewline "wow3" "wow$"
212 cat > expect << EOF
213 [beta] ; silly comment # another comment
214 noIndent= sillyValue ; 'nother silly comment
216 # empty line
217 ; comment
218 [nextSection]
219 nonewline = wow3
220 NoNewLine = wow2 for me
223 test_expect_success 'multivar replace' 'cmp .git/config expect'
225 test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline'
227 test_expect_failure 'ambiguous unset' \
228 'git-repo-config --unset nextsection.nonewline'
230 test_expect_failure 'invalid unset' \
231 'git-repo-config --unset somesection.nonewline'
233 git-repo-config --unset nextsection.nonewline "wow3$"
235 cat > expect << EOF
236 [beta] ; silly comment # another comment
237 noIndent= sillyValue ; 'nother silly comment
239 # empty line
240 ; comment
241 [nextSection]
242 NoNewLine = wow2 for me
245 test_expect_success 'multivar unset' 'cmp .git/config expect'
247 test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla'
249 test_expect_success 'correct key' 'git-repo-config 123456.a123 987'
251 test_expect_success 'hierarchical section' \
252 'git-repo-config 1.2.3.alpha beta'
254 cat > expect << EOF
255 [beta] ; silly comment # another comment
256 noIndent= sillyValue ; 'nother silly comment
258 # empty line
259 ; comment
260 [nextSection]
261 NoNewLine = wow2 for me
262 [123456]
263 a123 = 987
264 [1.2.3]
265 alpha = beta
268 test_expect_success 'hierarchical section value' 'cmp .git/config expect'
270 test_done