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