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