]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1300-repo-config.sh
t1300: put git invocations inside test function
[thirdparty/git.git] / t / t1300-repo-config.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Johannes Schindelin
4 #
5
6 test_description='Test git config in different settings'
7
8 . ./test-lib.sh
9
10 test_expect_success 'clear default config' '
11 rm -f .git/config
12 '
13
14 cat > expect << EOF
15 [core]
16 penguin = little blue
17 EOF
18 test_expect_success 'initial' '
19 git config core.penguin "little blue" &&
20 test_cmp expect .git/config
21 '
22
23 cat > expect << EOF
24 [core]
25 penguin = little blue
26 Movie = BadPhysics
27 EOF
28 test_expect_success 'mixed case' '
29 git config Core.Movie BadPhysics &&
30 test_cmp expect .git/config
31 '
32
33 cat > expect << EOF
34 [core]
35 penguin = little blue
36 Movie = BadPhysics
37 [Cores]
38 WhatEver = Second
39 EOF
40 test_expect_success 'similar section' '
41 git config Cores.WhatEver Second
42 test_cmp expect .git/config
43 '
44
45 cat > expect << EOF
46 [core]
47 penguin = little blue
48 Movie = BadPhysics
49 UPPERCASE = true
50 [Cores]
51 WhatEver = Second
52 EOF
53 test_expect_success 'uppercase section' '
54 git config CORE.UPPERCASE true &&
55 test_cmp expect .git/config
56 '
57
58 test_expect_success 'replace with non-match' \
59 'git config core.penguin kingpin !blue'
60
61 test_expect_success 'replace with non-match (actually matching)' \
62 'git config core.penguin "very blue" !kingpin'
63
64 cat > expect << EOF
65 [core]
66 penguin = very blue
67 Movie = BadPhysics
68 UPPERCASE = true
69 penguin = kingpin
70 [Cores]
71 WhatEver = Second
72 EOF
73
74 test_expect_success 'non-match result' 'test_cmp expect .git/config'
75
76 cat > .git/config <<\EOF
77 [alpha]
78 bar = foo
79 [beta]
80 baz = multiple \
81 lines
82 EOF
83
84 test_expect_success 'unset with cont. lines' \
85 'git config --unset beta.baz'
86
87 cat > expect <<\EOF
88 [alpha]
89 bar = foo
90 [beta]
91 EOF
92
93 test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config'
94
95 cat > .git/config << EOF
96 [beta] ; silly comment # another comment
97 noIndent= sillyValue ; 'nother silly comment
98
99 # empty line
100 ; comment
101 haha ="beta" # last silly comment
102 haha = hello
103 haha = bello
104 [nextSection] noNewline = ouch
105 EOF
106
107 cp .git/config .git/config2
108
109 test_expect_success 'multiple unset' \
110 'git config --unset-all beta.haha'
111
112 cat > expect << EOF
113 [beta] ; silly comment # another comment
114 noIndent= sillyValue ; 'nother silly comment
115
116 # empty line
117 ; comment
118 [nextSection] noNewline = ouch
119 EOF
120
121 test_expect_success 'multiple unset is correct' 'test_cmp expect .git/config'
122
123 cp .git/config2 .git/config
124
125 test_expect_success '--replace-all missing value' '
126 test_must_fail git config --replace-all beta.haha &&
127 test_cmp .git/config2 .git/config
128 '
129
130 rm .git/config2
131
132 test_expect_success '--replace-all' \
133 'git config --replace-all beta.haha gamma'
134
135 cat > expect << EOF
136 [beta] ; silly comment # another comment
137 noIndent= sillyValue ; 'nother silly comment
138
139 # empty line
140 ; comment
141 haha = gamma
142 [nextSection] noNewline = ouch
143 EOF
144
145 test_expect_success 'all replaced' 'test_cmp expect .git/config'
146
147 cat > expect << EOF
148 [beta] ; silly comment # another comment
149 noIndent= sillyValue ; 'nother silly comment
150
151 # empty line
152 ; comment
153 haha = alpha
154 [nextSection] noNewline = ouch
155 EOF
156 test_expect_success 'really mean test' '
157 git config beta.haha alpha &&
158 test_cmp expect .git/config
159 '
160
161 cat > expect << EOF
162 [beta] ; silly comment # another comment
163 noIndent= sillyValue ; 'nother silly comment
164
165 # empty line
166 ; comment
167 haha = alpha
168 [nextSection]
169 nonewline = wow
170 EOF
171 test_expect_success 'really really mean test' '
172 git config nextsection.nonewline wow &&
173 test_cmp expect .git/config
174 '
175
176 test_expect_success 'get value' 'test alpha = $(git config beta.haha)'
177
178 cat > expect << EOF
179 [beta] ; silly comment # another comment
180 noIndent= sillyValue ; 'nother silly comment
181
182 # empty line
183 ; comment
184 [nextSection]
185 nonewline = wow
186 EOF
187 test_expect_success 'unset' '
188 git config --unset beta.haha &&
189 test_cmp expect .git/config
190 '
191
192 cat > expect << EOF
193 [beta] ; silly comment # another comment
194 noIndent= sillyValue ; 'nother silly comment
195
196 # empty line
197 ; comment
198 [nextSection]
199 nonewline = wow
200 NoNewLine = wow2 for me
201 EOF
202 test_expect_success 'multivar' '
203 git config nextsection.NoNewLine "wow2 for me" "for me$" &&
204 test_cmp expect .git/config
205 '
206
207 test_expect_success 'non-match' \
208 'git config --get nextsection.nonewline !for'
209
210 test_expect_success 'non-match value' \
211 'test wow = $(git config --get nextsection.nonewline !for)'
212
213 test_expect_success 'ambiguous get' '
214 test_must_fail git config --get nextsection.nonewline
215 '
216
217 test_expect_success 'get multivar' \
218 'git config --get-all nextsection.nonewline'
219
220 cat > expect << EOF
221 [beta] ; silly comment # another comment
222 noIndent= sillyValue ; 'nother silly comment
223
224 # empty line
225 ; comment
226 [nextSection]
227 nonewline = wow3
228 NoNewLine = wow2 for me
229 EOF
230 test_expect_success 'multivar replace' '
231 git config nextsection.nonewline "wow3" "wow$" &&
232 test_cmp expect .git/config
233 '
234
235 test_expect_success 'ambiguous value' '
236 test_must_fail git config nextsection.nonewline
237 '
238
239 test_expect_success 'ambiguous unset' '
240 test_must_fail git config --unset nextsection.nonewline
241 '
242
243 test_expect_success 'invalid unset' '
244 test_must_fail git config --unset somesection.nonewline
245 '
246
247 cat > expect << EOF
248 [beta] ; silly comment # another comment
249 noIndent= sillyValue ; 'nother silly comment
250
251 # empty line
252 ; comment
253 [nextSection]
254 NoNewLine = wow2 for me
255 EOF
256
257 test_expect_success 'multivar unset' '
258 git config --unset nextsection.nonewline "wow3$" &&
259 test_cmp expect .git/config
260 '
261
262 test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
263
264 test_expect_success 'correct key' 'git config 123456.a123 987'
265
266 test_expect_success 'hierarchical section' \
267 'git config Version.1.2.3eX.Alpha beta'
268
269 cat > expect << EOF
270 [beta] ; silly comment # another comment
271 noIndent= sillyValue ; 'nother silly comment
272
273 # empty line
274 ; comment
275 [nextSection]
276 NoNewLine = wow2 for me
277 [123456]
278 a123 = 987
279 [Version "1.2.3eX"]
280 Alpha = beta
281 EOF
282
283 test_expect_success 'hierarchical section value' 'test_cmp expect .git/config'
284
285 cat > expect << EOF
286 beta.noindent=sillyValue
287 nextsection.nonewline=wow2 for me
288 123456.a123=987
289 version.1.2.3eX.alpha=beta
290 EOF
291
292 test_expect_success 'working --list' \
293 'git config --list > output && cmp output expect'
294
295 cat > expect << EOF
296 EOF
297
298 test_expect_success '--list without repo produces empty output' '
299 git --git-dir=nonexistent config --list >output &&
300 test_cmp expect output
301 '
302
303 cat > expect << EOF
304 beta.noindent sillyValue
305 nextsection.nonewline wow2 for me
306 EOF
307
308 test_expect_success '--get-regexp' \
309 'git config --get-regexp in > output && cmp output expect'
310
311 cat > expect << EOF
312 wow2 for me
313 wow4 for you
314 EOF
315
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 '
321
322 cat > .git/config << EOF
323 [novalue]
324 variable
325 [emptyvalue]
326 variable =
327 EOF
328
329 test_expect_success 'get variable with no value' \
330 'git config --get novalue.variable ^$'
331
332 test_expect_success 'get variable with empty value' \
333 'git config --get emptyvalue.variable ^$'
334
335 echo novalue.variable > expect
336
337 test_expect_success 'get-regexp variable with no value' \
338 'git config --get-regexp novalue > output &&
339 cmp output expect'
340
341 echo 'emptyvalue.variable ' > expect
342
343 test_expect_success 'get-regexp variable with empty value' \
344 'git config --get-regexp emptyvalue > output &&
345 cmp output expect'
346
347 echo true > expect
348
349 test_expect_success 'get bool variable with no value' \
350 'git config --bool novalue.variable > output &&
351 cmp output expect'
352
353 echo false > expect
354
355 test_expect_success 'get bool variable with empty value' \
356 'git config --bool emptyvalue.variable > output &&
357 cmp output expect'
358
359 test_expect_success 'no arguments, but no crash' '
360 test_must_fail git config >output 2>&1 &&
361 grep usage output
362 '
363
364 cat > .git/config << EOF
365 [a.b]
366 c = d
367 EOF
368
369 cat > expect << EOF
370 [a.b]
371 c = d
372 [a]
373 x = y
374 EOF
375
376 test_expect_success 'new section is partial match of another' '
377 git config a.x y &&
378 test_cmp expect .git/config
379 '
380
381 cat > expect << EOF
382 [a.b]
383 c = d
384 [a]
385 x = y
386 b = c
387 [b]
388 x = y
389 EOF
390
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 '
396
397 test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \
398 'test_must_fail git config --file non-existing-config -l'
399
400 cat > other-config << EOF
401 [ein]
402 bahn = strasse
403 EOF
404
405 cat > expect << EOF
406 ein.bahn=strasse
407 EOF
408
409 test_expect_success 'alternative GIT_CONFIG' '
410 GIT_CONFIG=other-config git config -l >output &&
411 test_cmp expect output
412 '
413
414 test_expect_success 'alternative GIT_CONFIG (--file)' \
415 'git config --file other-config -l > output && cmp output expect'
416
417 test_expect_success 'refer config from subdirectory' '
418 mkdir x &&
419 (
420 cd x &&
421 echo strasse >expect
422 git config --get --file ../other-config ein.bahn >actual &&
423 test_cmp expect actual
424 )
425
426 '
427
428 cat > expect << EOF
429 [ein]
430 bahn = strasse
431 [anwohner]
432 park = ausweis
433 EOF
434
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 '
439
440 cat > .git/config << EOF
441 # Hallo
442 #Bello
443 [branch "eins"]
444 x = 1
445 [branch.eins]
446 y = 1
447 [branch "1 234 blabl/a"]
448 weird
449 EOF
450
451 test_expect_success "rename section" \
452 "git config --rename-section branch.eins branch.zwei"
453
454 cat > expect << EOF
455 # Hallo
456 #Bello
457 [branch "zwei"]
458 x = 1
459 [branch "zwei"]
460 y = 1
461 [branch "1 234 blabl/a"]
462 weird
463 EOF
464
465 test_expect_success "rename succeeded" "test_cmp expect .git/config"
466
467 test_expect_success "rename non-existing section" '
468 test_must_fail git config --rename-section \
469 branch."world domination" branch.drei
470 '
471
472 test_expect_success "rename succeeded" "test_cmp expect .git/config"
473
474 test_expect_success "rename another section" \
475 'git config --rename-section branch."1 234 blabl/a" branch.drei'
476
477 cat > expect << EOF
478 # Hallo
479 #Bello
480 [branch "zwei"]
481 x = 1
482 [branch "zwei"]
483 y = 1
484 [branch "drei"]
485 weird
486 EOF
487
488 test_expect_success "rename succeeded" "test_cmp expect .git/config"
489
490 cat >> .git/config << EOF
491 [branch "vier"] z = 1
492 EOF
493
494 test_expect_success "rename a section with a var on the same line" \
495 'git config --rename-section branch.vier branch.zwei'
496
497 cat > expect << EOF
498 # Hallo
499 #Bello
500 [branch "zwei"]
501 x = 1
502 [branch "zwei"]
503 y = 1
504 [branch "drei"]
505 weird
506 [branch "zwei"]
507 z = 1
508 EOF
509
510 test_expect_success "rename succeeded" "test_cmp expect .git/config"
511
512 cat >> .git/config << EOF
513 [branch "zwei"] a = 1 [branch "vier"]
514 EOF
515
516 test_expect_success "remove section" "git config --remove-section branch.zwei"
517
518 cat > expect << EOF
519 # Hallo
520 #Bello
521 [branch "drei"]
522 weird
523 EOF
524
525 test_expect_success "section was removed properly" \
526 "test_cmp expect .git/config"
527
528 rm .git/config
529
530 cat > expect << EOF
531 [gitcvs]
532 enabled = true
533 dbname = %Ggitcvs2.%a.%m.sqlite
534 [gitcvs "ext"]
535 dbname = %Ggitcvs1.%a.%m.sqlite
536 EOF
537
538 test_expect_success 'section ending' '
539
540 git config gitcvs.enabled true &&
541 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
542 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
543 test_cmp expect .git/config
544
545 '
546
547 test_expect_success numbers '
548
549 git config kilo.gram 1k &&
550 git config mega.ton 1m &&
551 k=$(git config --int --get kilo.gram) &&
552 test z1024 = "z$k" &&
553 m=$(git config --int --get mega.ton) &&
554 test z1048576 = "z$m"
555 '
556
557 cat > expect <<EOF
558 fatal: bad config value for 'aninvalid.unit' in .git/config
559 EOF
560
561 test_expect_success 'invalid unit' '
562
563 git config aninvalid.unit "1auto" &&
564 s=$(git config aninvalid.unit) &&
565 test "z1auto" = "z$s" &&
566 if git config --int --get aninvalid.unit 2>actual
567 then
568 echo config should have failed
569 false
570 fi &&
571 cmp actual expect
572 '
573
574 cat > expect << EOF
575 true
576 false
577 true
578 false
579 true
580 false
581 true
582 false
583 EOF
584
585 test_expect_success bool '
586
587 git config bool.true1 01 &&
588 git config bool.true2 -1 &&
589 git config bool.true3 YeS &&
590 git config bool.true4 true &&
591 git config bool.false1 000 &&
592 git config bool.false2 "" &&
593 git config bool.false3 nO &&
594 git config bool.false4 FALSE &&
595 rm -f result &&
596 for i in 1 2 3 4
597 do
598 git config --bool --get bool.true$i >>result
599 git config --bool --get bool.false$i >>result
600 done &&
601 cmp expect result'
602
603 test_expect_success 'invalid bool (--get)' '
604
605 git config bool.nobool foobar &&
606 test_must_fail git config --bool --get bool.nobool'
607
608 test_expect_success 'invalid bool (set)' '
609
610 test_must_fail git config --bool bool.nobool foobar'
611
612 rm .git/config
613
614 cat > expect <<\EOF
615 [bool]
616 true1 = true
617 true2 = true
618 true3 = true
619 true4 = true
620 false1 = false
621 false2 = false
622 false3 = false
623 false4 = false
624 EOF
625
626 test_expect_success 'set --bool' '
627
628 git config --bool bool.true1 01 &&
629 git config --bool bool.true2 -1 &&
630 git config --bool bool.true3 YeS &&
631 git config --bool bool.true4 true &&
632 git config --bool bool.false1 000 &&
633 git config --bool bool.false2 "" &&
634 git config --bool bool.false3 nO &&
635 git config --bool bool.false4 FALSE &&
636 cmp expect .git/config'
637
638 rm .git/config
639
640 cat > expect <<\EOF
641 [int]
642 val1 = 1
643 val2 = -1
644 val3 = 5242880
645 EOF
646
647 test_expect_success 'set --int' '
648
649 git config --int int.val1 01 &&
650 git config --int int.val2 -1 &&
651 git config --int int.val3 5m &&
652 cmp expect .git/config'
653
654 rm .git/config
655
656 cat >expect <<\EOF
657 [bool]
658 true1 = true
659 true2 = true
660 false1 = false
661 false2 = false
662 [int]
663 int1 = 0
664 int2 = 1
665 int3 = -1
666 EOF
667
668 test_expect_success 'get --bool-or-int' '
669 (
670 echo "[bool]"
671 echo true1
672 echo true2 = true
673 echo false = false
674 echo "[int]"
675 echo int1 = 0
676 echo int2 = 1
677 echo int3 = -1
678 ) >>.git/config &&
679 test $(git config --bool-or-int bool.true1) = true &&
680 test $(git config --bool-or-int bool.true2) = true &&
681 test $(git config --bool-or-int bool.false) = false &&
682 test $(git config --bool-or-int int.int1) = 0 &&
683 test $(git config --bool-or-int int.int2) = 1 &&
684 test $(git config --bool-or-int int.int3) = -1
685
686 '
687
688 rm .git/config
689 cat >expect <<\EOF
690 [bool]
691 true1 = true
692 false1 = false
693 true2 = true
694 false2 = false
695 [int]
696 int1 = 0
697 int2 = 1
698 int3 = -1
699 EOF
700
701 test_expect_success 'set --bool-or-int' '
702 git config --bool-or-int bool.true1 true &&
703 git config --bool-or-int bool.false1 false &&
704 git config --bool-or-int bool.true2 yes &&
705 git config --bool-or-int bool.false2 no &&
706 git config --bool-or-int int.int1 0 &&
707 git config --bool-or-int int.int2 1 &&
708 git config --bool-or-int int.int3 -1 &&
709 test_cmp expect .git/config
710 '
711
712 rm .git/config
713
714 cat >expect <<\EOF
715 [path]
716 home = ~/
717 normal = /dev/null
718 trailingtilde = foo~
719 EOF
720
721 test_expect_success NOT_MINGW 'set --path' '
722 git config --path path.home "~/" &&
723 git config --path path.normal "/dev/null" &&
724 git config --path path.trailingtilde "foo~" &&
725 test_cmp expect .git/config'
726
727 if test_have_prereq NOT_MINGW && test "${HOME+set}"
728 then
729 test_set_prereq HOMEVAR
730 fi
731
732 cat >expect <<EOF
733 $HOME/
734 /dev/null
735 foo~
736 EOF
737
738 test_expect_success HOMEVAR 'get --path' '
739 git config --get --path path.home > result &&
740 git config --get --path path.normal >> result &&
741 git config --get --path path.trailingtilde >> result &&
742 test_cmp expect result
743 '
744
745 cat >expect <<\EOF
746 /dev/null
747 foo~
748 EOF
749
750 test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
751 (
752 unset HOME;
753 test_must_fail git config --get --path path.home \
754 >result 2>msg &&
755 git config --get --path path.normal >>result &&
756 git config --get --path path.trailingtilde >>result
757 ) &&
758 grep "[Ff]ailed to expand.*~/" msg &&
759 test_cmp expect result
760 '
761
762 cat > expect << EOF
763 [quote]
764 leading = " test"
765 ending = "test "
766 semicolon = "test;test"
767 hash = "test#test"
768 EOF
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 '
777
778 test_expect_success 'key with newline' '
779 test_must_fail git config "key.with
780 newline" 123'
781
782 test_expect_success 'value with newline' 'git config key.sub value.with\\\
783 newline'
784
785 cat > .git/config <<\EOF
786 [section]
787 ; comment \
788 continued = cont\
789 inued
790 noncont = not continued ; \
791 quotecont = "cont;\
792 inued"
793 EOF
794
795 cat > expect <<\EOF
796 section.continued=continued
797 section.noncont=not continued
798 section.quotecont=cont;inued
799 EOF
800
801 test_expect_success 'value continued on next line' '
802 git config --list > result &&
803 cmp result expect
804 '
805
806 cat > .git/config <<\EOF
807 [section "sub=section"]
808 val1 = foo=bar
809 val2 = foo\nbar
810 val3 = \n\n
811 val4 =
812 val5
813 EOF
814
815 cat > expect <<\EOF
816 section.sub=section.val1
817 foo=barQsection.sub=section.val2
818 foo
819 barQsection.sub=section.val3
820
821
822 Qsection.sub=section.val4
823 Qsection.sub=section.val5Q
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 '
830
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 '
836
837 test_expect_success 'inner whitespace kept verbatim' '
838 git config section.val "foo bar" &&
839 test "z$(git config section.val)" = "zfoo bar"
840 '
841
842 test_expect_success SYMLINKS 'symlinked configuration' '
843
844 ln -s notyet myconfig &&
845 GIT_CONFIG=myconfig git config test.frotz nitfol &&
846 test -h myconfig &&
847 test -f notyet &&
848 test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
849 GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
850 test -h myconfig &&
851 test -f notyet &&
852 test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
853 test "z$(GIT_CONFIG=notyet git config test.xyzzy)" = zrezrov
854
855 '
856
857 test_expect_success 'nonexistent configuration' '
858 (
859 GIT_CONFIG=doesnotexist &&
860 export GIT_CONFIG &&
861 test_must_fail git config --list &&
862 test_must_fail git config test.xyzzy
863 )
864 '
865
866 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
867 ln -s doesnotexist linktonada &&
868 ln -s linktonada linktolinktonada &&
869 (
870 GIT_CONFIG=linktonada &&
871 export GIT_CONFIG &&
872 test_must_fail git config --list &&
873 GIT_CONFIG=linktolinktonada &&
874 test_must_fail git config --list
875 )
876 '
877
878 test_expect_success 'check split_cmdline return' "
879 git config alias.split-cmdline-fix 'echo \"' &&
880 test_must_fail git split-cmdline-fix &&
881 echo foo > foo &&
882 git add foo &&
883 git commit -m 'initial commit' &&
884 git config branch.master.mergeoptions 'echo \"' &&
885 test_must_fail git merge master
886 "
887
888 test_expect_success 'git -c "key=value" support' '
889 test "z$(git -c core.name=value config core.name)" = zvalue &&
890 test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue &&
891 test "z$(git -c foo.flag config --bool foo.flag)" = ztrue &&
892 test_must_fail git -c name=value config core.name
893 '
894
895 test_expect_success 'key sanity-checking' '
896 test_must_fail git config foo=bar &&
897 test_must_fail git config foo=.bar &&
898 test_must_fail git config foo.ba=r &&
899 test_must_fail git config foo.1bar &&
900 test_must_fail git config foo."ba
901 z".bar &&
902 test_must_fail git config . false &&
903 test_must_fail git config .foo false &&
904 test_must_fail git config foo. false &&
905 test_must_fail git config .foo. false &&
906 git config foo.bar true &&
907 git config foo."ba =z".bar false
908 '
909
910 test_expect_success 'git -c works with aliases of builtins' '
911 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
912 echo bar >expect &&
913 git checkconfig >actual &&
914 test_cmp expect actual
915 '
916
917 test_expect_success 'git -c does not split values on equals' '
918 echo "value with = in it" >expect &&
919 git -c core.foo="value with = in it" config core.foo >actual &&
920 test_cmp expect actual
921 '
922
923 test_expect_success 'git -c dies on bogus config' '
924 test_must_fail git -c core.bare=foo rev-parse
925 '
926
927 test_expect_success 'git -c complains about empty key' '
928 test_must_fail git -c "=foo" rev-parse
929 '
930
931 test_expect_success 'git -c complains about empty key and value' '
932 test_must_fail git -c "" rev-parse
933 '
934
935 test_done