]>
Commit | Line | Data |
---|---|---|
942c1f53 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Johannes Schindelin | |
4 | # | |
5 | ||
ee72aeaf | 6 | test_description='Test git-repo-config in different settings' |
942c1f53 JS |
7 | |
8 | . ./test-lib.sh | |
9 | ||
10 | test -f .git/config && rm .git/config | |
11 | ||
ee72aeaf | 12 | git-repo-config core.penguin "little blue" |
942c1f53 JS |
13 | |
14 | cat > expect << EOF | |
942c1f53 JS |
15 | [core] |
16 | penguin = little blue | |
17 | EOF | |
18 | ||
19 | test_expect_success 'initial' 'cmp .git/config expect' | |
20 | ||
ee72aeaf | 21 | git-repo-config Core.Movie BadPhysics |
942c1f53 JS |
22 | |
23 | cat > expect << EOF | |
942c1f53 JS |
24 | [core] |
25 | penguin = little blue | |
26 | Movie = BadPhysics | |
27 | EOF | |
28 | ||
29 | test_expect_success 'mixed case' 'cmp .git/config expect' | |
30 | ||
ee72aeaf | 31 | git-repo-config Cores.WhatEver Second |
942c1f53 JS |
32 | |
33 | cat > expect << EOF | |
942c1f53 JS |
34 | [core] |
35 | penguin = little blue | |
36 | Movie = BadPhysics | |
37 | [Cores] | |
38 | WhatEver = Second | |
39 | EOF | |
40 | ||
41 | test_expect_success 'similar section' 'cmp .git/config expect' | |
42 | ||
ee72aeaf | 43 | git-repo-config CORE.UPPERCASE true |
942c1f53 JS |
44 | |
45 | cat > expect << EOF | |
942c1f53 JS |
46 | [core] |
47 | penguin = little blue | |
48 | Movie = BadPhysics | |
49 | UPPERCASE = true | |
50 | [Cores] | |
51 | WhatEver = Second | |
52 | EOF | |
53 | ||
54 | test_expect_success 'similar section' 'cmp .git/config expect' | |
55 | ||
f98d863d | 56 | test_expect_success 'replace with non-match' \ |
ee72aeaf | 57 | 'git-repo-config core.penguin kingpin !blue' |
f98d863d JS |
58 | |
59 | test_expect_success 'replace with non-match (actually matching)' \ | |
ee72aeaf | 60 | 'git-repo-config core.penguin "very blue" !kingpin' |
f98d863d JS |
61 | |
62 | cat > expect << EOF | |
f98d863d JS |
63 | [core] |
64 | penguin = very blue | |
65 | Movie = BadPhysics | |
66 | UPPERCASE = true | |
67 | penguin = kingpin | |
68 | [Cores] | |
69 | WhatEver = Second | |
70 | EOF | |
71 | ||
72 | test_expect_success 'non-match result' 'cmp .git/config expect' | |
73 | ||
942c1f53 JS |
74 | cat > .git/config << EOF |
75 | [beta] ; silly comment # another comment | |
76 | noIndent= sillyValue ; 'nother silly comment | |
77 | ||
78 | # empty line | |
79 | ; comment | |
80 | haha ="beta" # last silly comment | |
4ddba79d JS |
81 | haha = hello |
82 | haha = bello | |
942c1f53 JS |
83 | [nextSection] noNewline = ouch |
84 | EOF | |
85 | ||
4ddba79d JS |
86 | cp .git/config .git/config2 |
87 | ||
88 | test_expect_success 'multiple unset' \ | |
ee72aeaf | 89 | 'git-repo-config --unset-all beta.haha' |
4ddba79d JS |
90 | |
91 | cat > expect << EOF | |
92 | [beta] ; silly comment # another comment | |
93 | noIndent= sillyValue ; 'nother silly comment | |
94 | ||
95 | # empty line | |
96 | ; comment | |
97 | [nextSection] noNewline = ouch | |
98 | EOF | |
99 | ||
100 | test_expect_success 'multiple unset is correct' 'cmp .git/config expect' | |
101 | ||
102 | mv .git/config2 .git/config | |
103 | ||
104 | test_expect_success '--replace-all' \ | |
ee72aeaf | 105 | 'git-repo-config --replace-all beta.haha gamma' |
4ddba79d JS |
106 | |
107 | cat > expect << EOF | |
108 | [beta] ; silly comment # another comment | |
109 | noIndent= sillyValue ; 'nother silly comment | |
110 | ||
111 | # empty line | |
112 | ; comment | |
113 | haha = gamma | |
114 | [nextSection] noNewline = ouch | |
115 | EOF | |
116 | ||
117 | test_expect_success 'all replaced' 'cmp .git/config expect' | |
118 | ||
ee72aeaf | 119 | git-repo-config beta.haha alpha |
942c1f53 JS |
120 | |
121 | cat > expect << EOF | |
122 | [beta] ; silly comment # another comment | |
123 | noIndent= sillyValue ; 'nother silly comment | |
124 | ||
125 | # empty line | |
126 | ; comment | |
127 | haha = alpha | |
128 | [nextSection] noNewline = ouch | |
129 | EOF | |
130 | ||
131 | test_expect_success 'really mean test' 'cmp .git/config expect' | |
132 | ||
ee72aeaf | 133 | git-repo-config nextsection.nonewline wow |
942c1f53 JS |
134 | |
135 | cat > expect << EOF | |
136 | [beta] ; silly comment # another comment | |
137 | noIndent= sillyValue ; 'nother silly comment | |
138 | ||
139 | # empty line | |
140 | ; comment | |
141 | haha = alpha | |
142 | [nextSection] | |
143 | nonewline = wow | |
144 | EOF | |
145 | ||
146 | test_expect_success 'really really mean test' 'cmp .git/config expect' | |
147 | ||
ee72aeaf JS |
148 | test_expect_success 'get value' 'test alpha = $(git-repo-config beta.haha)' |
149 | git-repo-config --unset beta.haha | |
942c1f53 JS |
150 | |
151 | cat > expect << EOF | |
152 | [beta] ; silly comment # another comment | |
153 | noIndent= sillyValue ; 'nother silly comment | |
154 | ||
155 | # empty line | |
156 | ; comment | |
157 | [nextSection] | |
158 | nonewline = wow | |
159 | EOF | |
160 | ||
161 | test_expect_success 'unset' 'cmp .git/config expect' | |
162 | ||
ee72aeaf | 163 | git-repo-config nextsection.NoNewLine "wow2 for me" "for me$" |
942c1f53 JS |
164 | |
165 | cat > expect << EOF | |
166 | [beta] ; silly comment # another comment | |
167 | noIndent= sillyValue ; 'nother silly comment | |
168 | ||
169 | # empty line | |
170 | ; comment | |
171 | [nextSection] | |
172 | nonewline = wow | |
173 | NoNewLine = wow2 for me | |
174 | EOF | |
175 | ||
176 | test_expect_success 'multivar' 'cmp .git/config expect' | |
177 | ||
f98d863d | 178 | test_expect_success 'non-match' \ |
ee72aeaf | 179 | 'git-repo-config --get nextsection.nonewline !for' |
f98d863d JS |
180 | |
181 | test_expect_success 'non-match value' \ | |
ee72aeaf | 182 | 'test wow = $(git-repo-config --get nextsection.nonewline !for)' |
f98d863d | 183 | |
4ddba79d | 184 | test_expect_failure 'ambiguous get' \ |
ee72aeaf | 185 | 'git-repo-config --get nextsection.nonewline' |
4ddba79d JS |
186 | |
187 | test_expect_success 'get multivar' \ | |
ee72aeaf | 188 | 'git-repo-config --get-all nextsection.nonewline' |
4ddba79d | 189 | |
ee72aeaf | 190 | git-repo-config nextsection.nonewline "wow3" "wow$" |
942c1f53 JS |
191 | |
192 | cat > expect << EOF | |
193 | [beta] ; silly comment # another comment | |
194 | noIndent= sillyValue ; 'nother silly comment | |
195 | ||
196 | # empty line | |
197 | ; comment | |
198 | [nextSection] | |
199 | nonewline = wow3 | |
200 | NoNewLine = wow2 for me | |
201 | EOF | |
202 | ||
203 | test_expect_success 'multivar replace' 'cmp .git/config expect' | |
204 | ||
ee72aeaf | 205 | test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline' |
4ddba79d | 206 | |
942c1f53 | 207 | test_expect_failure 'ambiguous unset' \ |
ee72aeaf | 208 | 'git-repo-config --unset nextsection.nonewline' |
942c1f53 JS |
209 | |
210 | test_expect_failure 'invalid unset' \ | |
ee72aeaf | 211 | 'git-repo-config --unset somesection.nonewline' |
942c1f53 | 212 | |
ee72aeaf | 213 | git-repo-config --unset nextsection.nonewline "wow3$" |
942c1f53 JS |
214 | |
215 | cat > expect << EOF | |
216 | [beta] ; silly comment # another comment | |
217 | noIndent= sillyValue ; 'nother silly comment | |
218 | ||
219 | # empty line | |
220 | ; comment | |
221 | [nextSection] | |
222 | NoNewLine = wow2 for me | |
223 | EOF | |
224 | ||
225 | test_expect_success 'multivar unset' 'cmp .git/config expect' | |
226 | ||
ee72aeaf | 227 | test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla' |
942c1f53 | 228 | |
ee72aeaf | 229 | test_expect_success 'correct key' 'git-repo-config 123456.a123 987' |
942c1f53 | 230 | |
b17e659d | 231 | test_expect_success 'hierarchical section' \ |
ee72aeaf | 232 | 'git-repo-config 1.2.3.alpha beta' |
b17e659d JS |
233 | |
234 | cat > expect << EOF | |
235 | [beta] ; silly comment # another comment | |
236 | noIndent= sillyValue ; 'nother silly comment | |
237 | ||
238 | # empty line | |
239 | ; comment | |
240 | [nextSection] | |
241 | NoNewLine = wow2 for me | |
242 | [123456] | |
243 | a123 = 987 | |
244 | [1.2.3] | |
245 | alpha = beta | |
246 | EOF | |
247 | ||
248 | test_expect_success 'hierarchical section value' 'cmp .git/config expect' | |
249 | ||
2fa9a0fb JS |
250 | cat > expect << EOF |
251 | beta.noindent=sillyValue | |
252 | nextsection.nonewline=wow2 for me | |
253 | 123456.a123=987 | |
254 | 1.2.3.alpha=beta | |
255 | EOF | |
256 | ||
257 | test_expect_success 'working --list' \ | |
258 | 'git-repo-config --list > output && cmp output expect' | |
259 | ||
260 | cat > expect << EOF | |
261 | beta.noindent sillyValue | |
262 | nextsection.nonewline wow2 for me | |
263 | EOF | |
264 | ||
265 | test_expect_success '--get-regexp' \ | |
266 | 'git-repo-config --get-regexp in > output && cmp output expect' | |
267 | ||
f067a137 JF |
268 | cat > .git/config << EOF |
269 | [novalue] | |
270 | variable | |
271 | EOF | |
272 | ||
273 | test_expect_success 'get variable with no value' \ | |
274 | 'git-repo-config --get novalue.variable ^$' | |
275 | ||
2fa9a0fb JS |
276 | git-repo-config > output 2>&1 |
277 | ||
278 | test_expect_success 'no arguments, but no crash' \ | |
279 | "test $? = 129 && grep usage output" | |
280 | ||
bd886fd3 SE |
281 | cat > .git/config << EOF |
282 | [a.b] | |
283 | c = d | |
284 | EOF | |
285 | ||
286 | git-repo-config a.x y | |
287 | ||
288 | cat > expect << EOF | |
289 | [a.b] | |
290 | c = d | |
291 | [a] | |
292 | x = y | |
293 | EOF | |
294 | ||
295 | test_expect_success 'new section is partial match of another' 'cmp .git/config expect' | |
296 | ||
297 | git-repo-config b.x y | |
298 | git-repo-config a.b c | |
299 | ||
300 | cat > expect << EOF | |
301 | [a.b] | |
302 | c = d | |
303 | [a] | |
304 | x = y | |
305 | b = c | |
306 | [b] | |
307 | x = y | |
308 | EOF | |
309 | ||
310 | test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' | |
311 | ||
942c1f53 JS |
312 | test_done |
313 |