@@ -7,28 +7,28 @@ test_description='Test git config in different settings'
7
7
8
8
. ./test-lib.sh
9
9
10
- test -f .git/config && rm .git/ config
11
-
12
- git config core.penguin " little blue "
10
+ test_expect_success ' clear default config' '
11
+ rm -f .git/config
12
+ '
13
13
14
14
cat > expect << EOF
15
15
[core]
16
16
penguin = little blue
17
17
EOF
18
-
19
- test_expect_success ' initial ' ' cmp .git/config expect '
20
-
21
- git config Core.Movie BadPhysics
18
+ test_expect_success ' initial ' '
19
+ git config core.penguin "little blue" &&
20
+ test_cmp expect .git/config
21
+ '
22
22
23
23
cat > expect << EOF
24
24
[core]
25
25
penguin = little blue
26
26
Movie = BadPhysics
27
27
EOF
28
-
29
- test_expect_success ' mixed case ' ' cmp .git/config expect '
30
-
31
- git config Cores.WhatEver Second
28
+ test_expect_success ' mixed case ' '
29
+ git config Core.Movie BadPhysics &&
30
+ test_cmp expect .git/config
31
+ '
32
32
33
33
cat > expect << EOF
34
34
[core]
@@ -37,10 +37,10 @@ cat > expect << EOF
37
37
[Cores]
38
38
WhatEver = Second
39
39
EOF
40
-
41
- test_expect_success ' similar section ' ' cmp .git/config expect '
42
-
43
- git config CORE.UPPERCASE true
40
+ test_expect_success ' similar section ' '
41
+ git config Cores.WhatEver Second
42
+ test_cmp expect .git/config
43
+ '
44
44
45
45
cat > expect << EOF
46
46
[core]
@@ -50,8 +50,10 @@ cat > expect << EOF
50
50
[Cores]
51
51
WhatEver = Second
52
52
EOF
53
-
54
- test_expect_success ' similar section' ' cmp .git/config expect'
53
+ test_expect_success ' uppercase section' '
54
+ git config CORE.UPPERCASE true &&
55
+ test_cmp expect .git/config
56
+ '
55
57
56
58
test_expect_success ' replace with non-match' \
57
59
' git config core.penguin kingpin !blue'
@@ -69,7 +71,7 @@ cat > expect << EOF
69
71
WhatEver = Second
70
72
EOF
71
73
72
- test_expect_success ' non-match result' ' cmp .git/config expect '
74
+ test_expect_success ' non-match result' ' test_cmp expect .git/config'
73
75
74
76
cat > .git/config << \EOF
75
77
[alpha]
@@ -88,7 +90,7 @@ bar = foo
88
90
[beta]
89
91
EOF
90
92
91
- test_expect_success ' unset with cont. lines is correct' ' cmp .git/config expect '
93
+ test_expect_success ' unset with cont. lines is correct' ' test_cmp expect .git/config'
92
94
93
95
cat > .git/config << EOF
94
96
[beta] ; silly comment # another comment
@@ -116,7 +118,7 @@ noIndent= sillyValue ; 'nother silly comment
116
118
[nextSection] noNewline = ouch
117
119
EOF
118
120
119
- test_expect_success ' multiple unset is correct' ' cmp .git/config expect '
121
+ test_expect_success ' multiple unset is correct' ' test_cmp expect .git/config'
120
122
121
123
cp .git/config2 .git/config
122
124
@@ -140,9 +142,7 @@ noIndent= sillyValue ; 'nother silly comment
140
142
[nextSection] noNewline = ouch
141
143
EOF
142
144
143
- test_expect_success ' all replaced' ' cmp .git/config expect'
144
-
145
- git config beta.haha alpha
145
+ test_expect_success ' all replaced' ' test_cmp expect .git/config'
146
146
147
147
cat > expect << EOF
148
148
[beta] ; silly comment # another comment
@@ -153,10 +153,10 @@ noIndent= sillyValue ; 'nother silly comment
153
153
haha = alpha
154
154
[nextSection] noNewline = ouch
155
155
EOF
156
-
157
- test_expect_success ' really mean test ' ' cmp .git/config expect '
158
-
159
- git config nextsection.nonewline wow
156
+ test_expect_success ' really mean test ' '
157
+ git config beta.haha alpha &&
158
+ test_cmp expect .git/config
159
+ '
160
160
161
161
cat > expect << EOF
162
162
[beta] ; silly comment # another comment
@@ -168,11 +168,12 @@ noIndent= sillyValue ; 'nother silly comment
168
168
[nextSection]
169
169
nonewline = wow
170
170
EOF
171
-
172
- test_expect_success ' really really mean test' ' cmp .git/config expect'
171
+ test_expect_success ' really really mean test' '
172
+ git config nextsection.nonewline wow &&
173
+ test_cmp expect .git/config
174
+ '
173
175
174
176
test_expect_success ' get value' ' test alpha = $(git config beta.haha)'
175
- git config --unset beta.haha
176
177
177
178
cat > expect << EOF
178
179
[beta] ; silly comment # another comment
@@ -183,10 +184,10 @@ noIndent= sillyValue ; 'nother silly comment
183
184
[nextSection]
184
185
nonewline = wow
185
186
EOF
186
-
187
- test_expect_success ' unset' ' cmp .git/config expect '
188
-
189
- git config nextsection.NoNewLine " wow2 for me " " for me$ "
187
+ test_expect_success ' unset ' '
188
+ git config -- unset beta.haha &&
189
+ test_cmp expect .git/config
190
+ '
190
191
191
192
cat > expect << EOF
192
193
[beta] ; silly comment # another comment
@@ -198,8 +199,10 @@ noIndent= sillyValue ; 'nother silly comment
198
199
nonewline = wow
199
200
NoNewLine = wow2 for me
200
201
EOF
201
-
202
- test_expect_success ' multivar' ' cmp .git/config expect'
202
+ test_expect_success ' multivar' '
203
+ git config nextsection.NoNewLine "wow2 for me" "for me$" &&
204
+ test_cmp expect .git/config
205
+ '
203
206
204
207
test_expect_success ' non-match' \
205
208
' git config --get nextsection.nonewline !for'
@@ -214,8 +217,6 @@ test_expect_success 'ambiguous get' '
214
217
test_expect_success ' get multivar' \
215
218
' git config --get-all nextsection.nonewline'
216
219
217
- git config nextsection.nonewline " wow3" " wow$"
218
-
219
220
cat > expect << EOF
220
221
[beta] ; silly comment # another comment
221
222
noIndent= sillyValue ; 'nother silly comment
@@ -226,8 +227,10 @@ noIndent= sillyValue ; 'nother silly comment
226
227
nonewline = wow3
227
228
NoNewLine = wow2 for me
228
229
EOF
229
-
230
- test_expect_success ' multivar replace' ' cmp .git/config expect'
230
+ test_expect_success ' multivar replace' '
231
+ git config nextsection.nonewline "wow3" "wow$" &&
232
+ test_cmp expect .git/config
233
+ '
231
234
232
235
test_expect_success ' ambiguous value' '
233
236
test_must_fail git config nextsection.nonewline
@@ -241,8 +244,6 @@ test_expect_success 'invalid unset' '
241
244
test_must_fail git config --unset somesection.nonewline
242
245
'
243
246
244
- git config --unset nextsection.nonewline " wow3$"
245
-
246
247
cat > expect << EOF
247
248
[beta] ; silly comment # another comment
248
249
noIndent= sillyValue ; 'nother silly comment
@@ -253,7 +254,10 @@ noIndent= sillyValue ; 'nother silly comment
253
254
NoNewLine = wow2 for me
254
255
EOF
255
256
256
- test_expect_success ' multivar unset' ' cmp .git/config expect'
257
+ test_expect_success ' multivar unset' '
258
+ git config --unset nextsection.nonewline "wow3$" &&
259
+ test_cmp expect .git/config
260
+ '
257
261
258
262
test_expect_success ' invalid key' ' test_must_fail git config inval.2key blabla'
259
263
@@ -276,7 +280,7 @@ noIndent= sillyValue ; 'nother silly comment
276
280
Alpha = beta
277
281
EOF
278
282
279
- test_expect_success ' hierarchical section value' ' cmp .git/config expect '
283
+ test_expect_success ' hierarchical section value' ' test_cmp expect .git/config'
280
284
281
285
cat > expect << EOF
282
286
beta.noindent=sillyValue
@@ -304,15 +308,16 @@ EOF
304
308
test_expect_success ' --get-regexp' \
305
309
' git config --get-regexp in > output && cmp output expect'
306
310
307
- git config --add nextsection.nonewline " wow4 for you"
308
-
309
311
cat > expect << EOF
310
312
wow2 for me
311
313
wow4 for you
312
314
EOF
313
315
314
- test_expect_success ' --add' \
315
- ' git config --get-all nextsection.nonewline > output && cmp output expect'
316
+ test_expect_success ' --add' '
317
+ git config --add nextsection.nonewline "wow4 for you" &&
318
+ git config --get-all nextsection.nonewline > output &&
319
+ test_cmp expect output
320
+ '
316
321
317
322
cat > .git/config << EOF
318
323
[novalue]
@@ -361,19 +366,17 @@ cat > .git/config << EOF
361
366
c = d
362
367
EOF
363
368
364
- git config a.x y
365
-
366
369
cat > expect << EOF
367
370
[a.b]
368
371
c = d
369
372
[a]
370
373
x = y
371
374
EOF
372
375
373
- test_expect_success ' new section is partial match of another' ' cmp .git/config expect '
374
-
375
- git config b.x y
376
- git config a.b c
376
+ test_expect_success ' new section is partial match of another' '
377
+ git config a.x y &&
378
+ test_cmp expect .git/config
379
+ '
377
380
378
381
cat > expect << EOF
379
382
[a.b]
@@ -385,7 +388,11 @@ cat > expect << EOF
385
388
x = y
386
389
EOF
387
390
388
- test_expect_success ' new variable inserts into proper section' ' cmp .git/config expect'
391
+ test_expect_success ' new variable inserts into proper section' '
392
+ git config b.x y &&
393
+ git config a.b c &&
394
+ test_cmp expect .git/config
395
+ '
389
396
390
397
test_expect_success ' alternative GIT_CONFIG (non-existing file should fail)' \
391
398
' test_must_fail git config --file non-existing-config -l'
@@ -399,9 +406,10 @@ cat > expect << EOF
399
406
ein.bahn=strasse
400
407
EOF
401
408
402
- GIT_CONFIG=other-config git config -l > output
403
-
404
- test_expect_success ' alternative GIT_CONFIG' ' cmp output expect'
409
+ test_expect_success ' alternative GIT_CONFIG' '
410
+ GIT_CONFIG=other-config git config -l >output &&
411
+ test_cmp expect output
412
+ '
405
413
406
414
test_expect_success ' alternative GIT_CONFIG (--file)' \
407
415
' git config --file other-config -l > output && cmp output expect'
@@ -417,16 +425,17 @@ test_expect_success 'refer config from subdirectory' '
417
425
418
426
'
419
427
420
- GIT_CONFIG=other-config git config anwohner.park ausweis
421
-
422
428
cat > expect << EOF
423
429
[ein]
424
430
bahn = strasse
425
431
[anwohner]
426
432
park = ausweis
427
433
EOF
428
434
429
- test_expect_success ' --set in alternative GIT_CONFIG' ' cmp other-config expect'
435
+ test_expect_success ' --set in alternative GIT_CONFIG' '
436
+ GIT_CONFIG=other-config git config anwohner.park ausweis &&
437
+ test_cmp expect other-config
438
+ '
430
439
431
440
cat > .git/config << EOF
432
441
# Hallo
@@ -531,7 +540,7 @@ test_expect_success 'section ending' '
531
540
git config gitcvs.enabled true &&
532
541
git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
533
542
git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
534
- cmp .git/config expect
543
+ test_cmp expect .git/config
535
544
536
545
'
537
546
@@ -750,22 +759,21 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
750
759
test_cmp expect result
751
760
'
752
761
753
- rm .git/config
754
-
755
- git config quote.leading " test"
756
- git config quote.ending " test "
757
- git config quote.semicolon " test;test"
758
- git config quote.hash " test#test"
759
-
760
762
cat > expect << EOF
761
763
[quote]
762
764
leading = " test"
763
765
ending = "test "
764
766
semicolon = "test;test"
765
767
hash = "test#test"
766
768
EOF
767
-
768
- test_expect_success ' quoting' ' cmp .git/config expect'
769
+ test_expect_success ' quoting' '
770
+ rm .git/config &&
771
+ git config quote.leading " test" &&
772
+ git config quote.ending "test " &&
773
+ git config quote.semicolon "test;test" &&
774
+ git config quote.hash "test#test" &&
775
+ test_cmp expect .git/config
776
+ '
769
777
770
778
test_expect_success ' key with newline' '
771
779
test_must_fail git config "key.with
@@ -790,9 +798,10 @@ section.noncont=not continued
790
798
section.quotecont=cont;inued
791
799
EOF
792
800
793
- git config --list > result
794
-
795
- test_expect_success ' value continued on next line' ' cmp result expect'
801
+ test_expect_success ' value continued on next line' '
802
+ git config --list > result &&
803
+ cmp result expect
804
+ '
796
805
797
806
cat > .git/config << \EOF
798
807
[section "sub=section"]
@@ -813,16 +822,17 @@ barQsection.sub=section.val3
813
822
Qsection.sub=section.val4
814
823
Qsection.sub=section.val5Q
815
824
EOF
825
+ test_expect_success ' --null --list' '
826
+ git config --null --list | nul_to_q >result &&
827
+ echo >>result &&
828
+ test_cmp expect result
829
+ '
816
830
817
- git config --null --list | perl -pe ' y/\000/Q/' > result
818
- echo >> result
819
-
820
- test_expect_success ' --null --list' ' cmp result expect'
821
-
822
- git config --null --get-regexp ' val[0-9]' | perl -pe ' y/\000/Q/' > result
823
- echo >> result
824
-
825
- test_expect_success ' --null --get-regexp' ' cmp result expect'
831
+ test_expect_success ' --null --get-regexp' '
832
+ git config --null --get-regexp "val[0-9]" | nul_to_q >result &&
833
+ echo >>result &&
834
+ test_cmp expect result
835
+ '
826
836
827
837
test_expect_success ' inner whitespace kept verbatim' '
828
838
git config section.val "foo bar" &&
0 commit comments