3 # Copyright (c) 2005 Johannes Schindelin
6 test_description
='Test git-repo-config in different settings'
10 test -f .git
/config
&& rm .git
/config
12 git-repo-config core.penguin
"little blue"
19 test_expect_success
'initial' 'cmp .git/config expect'
21 git-repo-config Core.Movie BadPhysics
29 test_expect_success
'mixed case' 'cmp .git/config expect'
31 git-repo-config Cores.WhatEver Second
41 test_expect_success
'similar section' 'cmp .git/config expect'
43 git-repo-config CORE.UPPERCASE true
54 test_expect_success
'similar section' 'cmp .git/config expect'
56 test_expect_success
'replace with non-match' \
57 'git-repo-config core.penguin kingpin !blue'
59 test_expect_success
'replace with non-match (actually matching)' \
60 'git-repo-config core.penguin "very blue" !kingpin'
72 test_expect_success
'non-match result' 'cmp .git/config expect'
74 cat > .git
/config
<< EOF
75 [beta] ; silly comment # another comment
76 noIndent= sillyValue ; 'nother silly comment
80 haha ="beta" # last silly comment
83 [nextSection] noNewline = ouch
86 cp .git
/config .git
/config2
88 test_expect_success
'multiple unset' \
89 'git-repo-config --unset-all beta.haha'
92 [beta] ; silly comment # another comment
93 noIndent= sillyValue ; 'nother silly comment
97 [nextSection] noNewline = ouch
100 test_expect_success
'multiple unset is correct' 'cmp .git/config expect'
102 mv .git
/config2 .git
/config
104 test_expect_success
'--replace-all' \
105 'git-repo-config --replace-all beta.haha gamma'
108 [beta] ; silly comment # another comment
109 noIndent= sillyValue ; 'nother silly comment
114 [nextSection] noNewline = ouch
117 test_expect_success
'all replaced' 'cmp .git/config expect'
119 git-repo-config beta.haha alpha
122 [beta] ; silly comment # another comment
123 noIndent= sillyValue ; 'nother silly comment
128 [nextSection] noNewline = ouch
131 test_expect_success
'really mean test' 'cmp .git/config expect'
133 git-repo-config nextsection.nonewline wow
136 [beta] ; silly comment # another comment
137 noIndent= sillyValue ; 'nother silly comment
146 test_expect_success
'really really mean test' 'cmp .git/config expect'
148 test_expect_success
'get value' 'test alpha = $(git-repo-config beta.haha)'
149 git-repo-config
--unset beta.haha
152 [beta] ; silly comment # another comment
153 noIndent= sillyValue ; 'nother silly comment
161 test_expect_success
'unset' 'cmp .git/config expect'
163 git-repo-config nextsection.NoNewLine
"wow2 for me" "for me$"
166 [beta] ; silly comment # another comment
167 noIndent= sillyValue ; 'nother silly comment
173 NoNewLine = wow2 for me
176 test_expect_success
'multivar' 'cmp .git/config expect'
178 test_expect_success
'non-match' \
179 'git-repo-config --get nextsection.nonewline !for'
181 test_expect_success
'non-match value' \
182 'test wow = $(git-repo-config --get nextsection.nonewline !for)'
184 test_expect_failure
'ambiguous get' \
185 'git-repo-config --get nextsection.nonewline'
187 test_expect_success
'get multivar' \
188 'git-repo-config --get-all nextsection.nonewline'
190 git-repo-config nextsection.nonewline
"wow3" "wow$"
193 [beta] ; silly comment # another comment
194 noIndent= sillyValue ; 'nother silly comment
200 NoNewLine = wow2 for me
203 test_expect_success
'multivar replace' 'cmp .git/config expect'
205 test_expect_failure
'ambiguous value' 'git-repo-config nextsection.nonewline'
207 test_expect_failure
'ambiguous unset' \
208 'git-repo-config --unset nextsection.nonewline'
210 test_expect_failure
'invalid unset' \
211 'git-repo-config --unset somesection.nonewline'
213 git-repo-config
--unset nextsection.nonewline
"wow3$"
216 [beta] ; silly comment # another comment
217 noIndent= sillyValue ; 'nother silly comment
222 NoNewLine = wow2 for me
225 test_expect_success
'multivar unset' 'cmp .git/config expect'
227 test_expect_failure
'invalid key' 'git-repo-config inval.2key blabla'
229 test_expect_success
'correct key' 'git-repo-config 123456.a123 987'
231 test_expect_success
'hierarchical section' \
232 'git-repo-config 1.2.3.alpha beta'
235 [beta] ; silly comment # another comment
236 noIndent= sillyValue ; 'nother silly comment
241 NoNewLine = wow2 for me
248 test_expect_success
'hierarchical section value' 'cmp .git/config expect'
251 beta.noindent=sillyValue
252 nextsection.nonewline=wow2 for me
257 test_expect_success
'working --list' \
258 'git-repo-config --list > output && cmp output expect'
261 beta.noindent sillyValue
262 nextsection.nonewline wow2 for me
265 test_expect_success
'--get-regexp' \
266 'git-repo-config --get-regexp in > output && cmp output expect'
268 cat > .git
/config
<< EOF
273 test_expect_success
'get variable with no value' \
274 'git-repo-config --get novalue.variable ^$'
276 git-repo-config
> output
2>&1
278 test_expect_success
'no arguments, but no crash' \
279 "test $? = 129 && grep usage output"