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 cat > .git/config << EOF
73 [beta] ; silly comment # another comment
74 noIndent= sillyValue ; 'nother silly comment
78 haha ="beta" # last silly comment
81 [nextSection] noNewline = ouch
84 cp .git/config .git/config2
86 test_expect_success 'multiple unset' \
87 'git-config-set --unset-all beta.haha'
90 [beta] ; silly comment # another comment
91 noIndent= sillyValue ; 'nother silly comment
95 [nextSection] noNewline = ouch
98 test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
100 mv .git/config2 .git/config
102 test_expect_success '--replace-all' \
103 'git-config-set --replace-all beta.haha gamma'
106 [beta] ; silly comment # another comment
107 noIndent= sillyValue ; 'nother silly comment
112 [nextSection] noNewline = ouch
115 test_expect_success 'all replaced' 'cmp .git/config expect'
117 git-config-set beta.haha alpha
120 [beta] ; silly comment # another comment
121 noIndent= sillyValue ; 'nother silly comment
126 [nextSection] noNewline = ouch
129 test_expect_success 'really mean test' 'cmp .git/config expect'
131 git-config-set nextsection.nonewline wow
134 [beta] ; silly comment # another comment
135 noIndent= sillyValue ; 'nother silly comment
144 test_expect_success 'really really mean test' 'cmp .git/config expect'
146 test_expect_success 'get value' 'test alpha = $(git-config-set beta.haha)'
147 git-config-set --unset beta.haha
150 [beta] ; silly comment # another comment
151 noIndent= sillyValue ; 'nother silly comment
159 test_expect_success 'unset' 'cmp .git/config expect'
161 git-config-set nextsection.NoNewLine "wow2 for me" "for me$"
164 [beta] ; silly comment # another comment
165 noIndent= sillyValue ; 'nother silly comment
171 NoNewLine = wow2 for me
174 test_expect_success 'multivar' 'cmp .git/config expect'
176 test_expect_failure 'ambiguous get' \
177 'git-config-set --get nextsection.nonewline'
179 test_expect_success 'get multivar' \
180 'git-config-set --get-all nextsection.nonewline'
182 git-config-set nextsection.nonewline "wow3" "wow$"
185 [beta] ; silly comment # another comment
186 noIndent= sillyValue ; 'nother silly comment
192 NoNewLine = wow2 for me
195 test_expect_success 'multivar replace' 'cmp .git/config expect'
197 test_expect_failure 'ambiguous value' 'git-config-set nextsection.nonewline'
199 test_expect_failure 'ambiguous unset' \
200 'git-config-set --unset nextsection.nonewline'
202 test_expect_failure 'invalid unset' \
203 'git-config-set --unset somesection.nonewline'
205 git-config-set --unset nextsection.nonewline "wow3$"
208 [beta] ; silly comment # another comment
209 noIndent= sillyValue ; 'nother silly comment
214 NoNewLine = wow2 for me
217 test_expect_success 'multivar unset' 'cmp .git/config expect'
219 test_expect_failure 'invalid key' 'git-config-set inval.2key blabla'
221 test_expect_success 'correct key' 'git-config-set 123456.a123 987'