3 # Copyright (c) 2005 Johannes Schindelin
6 test_description
='Test git-config-set in different settings'
10 test -f .git
/config
&& rm .git
/config
12 git-config-set core.penguin
"little blue"
16 # This is the config file
23 test_expect_success
'initial' 'cmp .git/config expect'
25 git-config-set Core.Movie BadPhysics
29 # This is the config file
37 test_expect_success
'mixed case' 'cmp .git/config expect'
39 git-config-set Cores.WhatEver Second
43 # This is the config file
53 test_expect_success
'similar section' 'cmp .git/config expect'
55 git-config-set CORE.UPPERCASE true
59 # This is the config file
70 test_expect_success
'similar section' 'cmp .git/config expect'
72 test_expect_success
'replace with non-match' \
73 'git-config-set core.penguin kingpin !blue'
75 test_expect_success
'replace with non-match (actually matching)' \
76 'git-config-set core.penguin "very blue" !kingpin'
80 # This is the config file
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
100 haha ="beta" # last silly comment
103 [nextSection] noNewline = ouch
106 cp .git
/config .git
/config2
108 test_expect_success
'multiple unset' \
109 'git-config-set --unset-all beta.haha'
112 [beta] ; silly comment # another comment
113 noIndent= sillyValue ; 'nother silly 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-config-set --replace-all beta.haha gamma'
128 [beta] ; silly comment # another comment
129 noIndent= sillyValue ; 'nother silly comment
134 [nextSection] noNewline = ouch
137 test_expect_success
'all replaced' 'cmp .git/config expect'
139 git-config-set beta.haha alpha
142 [beta] ; silly comment # another comment
143 noIndent= sillyValue ; 'nother silly comment
148 [nextSection] noNewline = ouch
151 test_expect_success
'really mean test' 'cmp .git/config expect'
153 git-config-set nextsection.nonewline wow
156 [beta] ; silly comment # another comment
157 noIndent= sillyValue ; 'nother silly comment
166 test_expect_success
'really really mean test' 'cmp .git/config expect'
168 test_expect_success
'get value' 'test alpha = $(git-config-set beta.haha)'
169 git-config-set
--unset beta.haha
172 [beta] ; silly comment # another comment
173 noIndent= sillyValue ; 'nother silly comment
181 test_expect_success
'unset' 'cmp .git/config expect'
183 git-config-set nextsection.NoNewLine
"wow2 for me" "for me$"
186 [beta] ; silly comment # another comment
187 noIndent= sillyValue ; 'nother silly comment
193 NoNewLine = wow2 for me
196 test_expect_success
'multivar' 'cmp .git/config expect'
198 test_expect_success
'non-match' \
199 'git-config-set --get nextsection.nonewline !for'
201 test_expect_success
'non-match value' \
202 'test wow = $(git-config-set --get nextsection.nonewline !for)'
204 test_expect_failure
'ambiguous get' \
205 'git-config-set --get nextsection.nonewline'
207 test_expect_success
'get multivar' \
208 'git-config-set --get-all nextsection.nonewline'
210 git-config-set nextsection.nonewline
"wow3" "wow$"
213 [beta] ; silly comment # another comment
214 noIndent= sillyValue ; 'nother silly comment
220 NoNewLine = wow2 for me
223 test_expect_success
'multivar replace' 'cmp .git/config expect'
225 test_expect_failure
'ambiguous value' 'git-config-set nextsection.nonewline'
227 test_expect_failure
'ambiguous unset' \
228 'git-config-set --unset nextsection.nonewline'
230 test_expect_failure
'invalid unset' \
231 'git-config-set --unset somesection.nonewline'
233 git-config-set
--unset nextsection.nonewline
"wow3$"
236 [beta] ; silly comment # another comment
237 noIndent= sillyValue ; 'nother silly comment
242 NoNewLine = wow2 for me
245 test_expect_success
'multivar unset' 'cmp .git/config expect'
247 test_expect_failure
'invalid key' 'git-config-set inval.2key blabla'
249 test_expect_success
'correct key' 'git-config-set 123456.a123 987'
251 test_expect_success
'hierarchical section' \
252 'git-config-set 1.2.3.alpha beta'
255 [beta] ; silly comment # another comment
256 noIndent= sillyValue ; 'nother silly comment
261 NoNewLine = wow2 for me
268 test_expect_success
'hierarchical section value' 'cmp .git/config expect'