Make git-send-pack exit with error when some refs couldn't be pushed out
[git/dscho.git] / t / t1300-repo-config.sh
blob207dd3de6484518018b4eb7efe26dc449a9f71cd
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
15 [core]
16 penguin = little blue
17 EOF
19 test_expect_success 'initial' 'cmp .git/config expect'
21 git-repo-config Core.Movie BadPhysics
23 cat > expect << EOF
24 [core]
25 penguin = little blue
26 Movie = BadPhysics
27 EOF
29 test_expect_success 'mixed case' 'cmp .git/config expect'
31 git-repo-config Cores.WhatEver Second
33 cat > expect << EOF
34 [core]
35 penguin = little blue
36 Movie = BadPhysics
37 [Cores]
38 WhatEver = Second
39 EOF
41 test_expect_success 'similar section' 'cmp .git/config expect'
43 git-repo-config CORE.UPPERCASE true
45 cat > expect << EOF
46 [core]
47 penguin = little blue
48 Movie = BadPhysics
49 UPPERCASE = true
50 [Cores]
51 WhatEver = Second
52 EOF
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'
62 cat > expect << EOF
63 [core]
64 penguin = very blue
65 Movie = BadPhysics
66 UPPERCASE = true
67 penguin = kingpin
68 [Cores]
69 WhatEver = Second
70 EOF
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
78 # empty line
79 ; comment
80 haha ="beta" # last silly comment
81 haha = hello
82 haha = bello
83 [nextSection] noNewline = ouch
84 EOF
86 cp .git/config .git/config2
88 test_expect_success 'multiple unset' \
89 'git-repo-config --unset-all beta.haha'
91 cat > expect << EOF
92 [beta] ; silly comment # another comment
93 noIndent= sillyValue ; 'nother silly comment
95 # empty line
96 ; comment
97 [nextSection] noNewline = ouch
98 EOF
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'
107 cat > expect << EOF
108 [beta] ; silly comment # another comment
109 noIndent= sillyValue ; 'nother silly comment
111 # empty line
112 ; comment
113 haha = gamma
114 [nextSection] noNewline = ouch
117 test_expect_success 'all replaced' 'cmp .git/config expect'
119 git-repo-config beta.haha alpha
121 cat > expect << EOF
122 [beta] ; silly comment # another comment
123 noIndent= sillyValue ; 'nother silly comment
125 # empty line
126 ; comment
127 haha = alpha
128 [nextSection] noNewline = ouch
131 test_expect_success 'really mean test' 'cmp .git/config expect'
133 git-repo-config nextsection.nonewline wow
135 cat > expect << EOF
136 [beta] ; silly comment # another comment
137 noIndent= sillyValue ; 'nother silly comment
139 # empty line
140 ; comment
141 haha = alpha
142 [nextSection]
143 nonewline = wow
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
151 cat > expect << EOF
152 [beta] ; silly comment # another comment
153 noIndent= sillyValue ; 'nother silly comment
155 # empty line
156 ; comment
157 [nextSection]
158 nonewline = wow
161 test_expect_success 'unset' 'cmp .git/config expect'
163 git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
165 cat > expect << EOF
166 [beta] ; silly comment # another comment
167 noIndent= sillyValue ; 'nother silly comment
169 # empty line
170 ; comment
171 [nextSection]
172 nonewline = wow
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$"
192 cat > expect << EOF
193 [beta] ; silly comment # another comment
194 noIndent= sillyValue ; 'nother silly comment
196 # empty line
197 ; comment
198 [nextSection]
199 nonewline = wow3
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$"
215 cat > expect << EOF
216 [beta] ; silly comment # another comment
217 noIndent= sillyValue ; 'nother silly comment
219 # empty line
220 ; comment
221 [nextSection]
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'
234 cat > expect << EOF
235 [beta] ; silly comment # another comment
236 noIndent= sillyValue ; 'nother silly comment
238 # empty line
239 ; comment
240 [nextSection]
241 NoNewLine = wow2 for me
242 [123456]
243 a123 = 987
244 [1.2.3]
245 alpha = beta
248 test_expect_success 'hierarchical section value' 'cmp .git/config expect'
250 test_done