tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
[git/debian.git] / t / t1300-config.sh
blob84e88cf5a93b167815a1691d640c16b845e9514a
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test git config in different settings'
8 . ./test-lib.sh
10 test_expect_success 'clear default config' '
11 rm -f .git/config
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
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
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
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
58 test_expect_success 'replace with non-match' '
59 git config core.penguin kingpin !blue
62 test_expect_success 'replace with non-match (actually matching)' '
63 git config core.penguin "very blue" !kingpin
66 cat > expect << EOF
67 [core]
68 penguin = very blue
69 Movie = BadPhysics
70 UPPERCASE = true
71 penguin = kingpin
72 [Cores]
73 WhatEver = Second
74 EOF
76 test_expect_success 'non-match result' 'test_cmp expect .git/config'
78 test_expect_success 'find mixed-case key by canonical name' '
79 echo Second >expect &&
80 git config cores.whatever >actual &&
81 test_cmp expect actual
84 test_expect_success 'find mixed-case key by non-canonical name' '
85 echo Second >expect &&
86 git config CoReS.WhAtEvEr >actual &&
87 test_cmp expect actual
90 test_expect_success 'subsections are not canonicalized by git-config' '
91 cat >>.git/config <<-\EOF &&
92 [section.SubSection]
93 key = one
94 [section "SubSection"]
95 key = two
96 EOF
97 echo one >expect &&
98 git config section.subsection.key >actual &&
99 test_cmp expect actual &&
100 echo two >expect &&
101 git config section.SubSection.key >actual &&
102 test_cmp expect actual
105 cat > .git/config <<\EOF
106 [alpha]
107 bar = foo
108 [beta]
109 baz = multiple \
110 lines
111 foo = bar
114 test_expect_success 'unset with cont. lines' '
115 git config --unset beta.baz
118 cat > expect <<\EOF
119 [alpha]
120 bar = foo
121 [beta]
122 foo = bar
125 test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config'
127 cat > .git/config << EOF
128 [beta] ; silly comment # another comment
129 noIndent= sillyValue ; 'nother silly comment
131 # empty line
132 ; comment
133 haha ="beta" # last silly comment
134 haha = hello
135 haha = bello
136 [nextSection] noNewline = ouch
139 cp .git/config .git/config2
141 test_expect_success 'multiple unset' '
142 git config --unset-all beta.haha
145 cat > expect << EOF
146 [beta] ; silly comment # another comment
147 noIndent= sillyValue ; 'nother silly comment
149 # empty line
150 ; comment
151 [nextSection] noNewline = ouch
154 test_expect_success 'multiple unset is correct' '
155 test_cmp expect .git/config
158 cp .git/config2 .git/config
160 test_expect_success '--replace-all missing value' '
161 test_must_fail git config --replace-all beta.haha &&
162 test_cmp .git/config2 .git/config
165 rm .git/config2
167 test_expect_success '--replace-all' '
168 git config --replace-all beta.haha gamma
171 cat > expect << EOF
172 [beta] ; silly comment # another comment
173 noIndent= sillyValue ; 'nother silly comment
175 # empty line
176 ; comment
177 haha = gamma
178 [nextSection] noNewline = ouch
181 test_expect_success 'all replaced' '
182 test_cmp expect .git/config
185 cat > expect << EOF
186 [beta] ; silly comment # another comment
187 noIndent= sillyValue ; 'nother silly comment
189 # empty line
190 ; comment
191 haha = alpha
192 [nextSection] noNewline = ouch
194 test_expect_success 'really mean test' '
195 git config beta.haha alpha &&
196 test_cmp expect .git/config
199 cat > expect << EOF
200 [beta] ; silly comment # another comment
201 noIndent= sillyValue ; 'nother silly comment
203 # empty line
204 ; comment
205 haha = alpha
206 [nextSection]
207 nonewline = wow
209 test_expect_success 'really really mean test' '
210 git config nextsection.nonewline wow &&
211 test_cmp expect .git/config
214 test_expect_success 'get value' '
215 echo alpha >expect &&
216 git config beta.haha >actual &&
217 test_cmp expect actual
220 cat > expect << EOF
221 [beta] ; silly comment # another comment
222 noIndent= sillyValue ; 'nother silly comment
224 # empty line
225 ; comment
226 [nextSection]
227 nonewline = wow
229 test_expect_success 'unset' '
230 git config --unset beta.haha &&
231 test_cmp expect .git/config
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 = wow
242 NoNewLine = wow2 for me
244 test_expect_success 'multivar' '
245 git config nextsection.NoNewLine "wow2 for me" "for me$" &&
246 test_cmp expect .git/config
249 test_expect_success 'non-match' '
250 git config --get nextsection.nonewline !for
253 test_expect_success 'non-match value' '
254 echo wow >expect &&
255 git config --get nextsection.nonewline !for >actual &&
256 test_cmp expect actual
259 test_expect_success 'multi-valued get returns final one' '
260 echo "wow2 for me" >expect &&
261 git config --get nextsection.nonewline >actual &&
262 test_cmp expect actual
265 test_expect_success 'multi-valued get-all returns all' '
266 cat >expect <<-\EOF &&
268 wow2 for me
270 git config --get-all nextsection.nonewline >actual &&
271 test_cmp expect actual
274 cat > expect << EOF
275 [beta] ; silly comment # another comment
276 noIndent= sillyValue ; 'nother silly comment
278 # empty line
279 ; comment
280 [nextSection]
281 nonewline = wow3
282 NoNewLine = wow2 for me
284 test_expect_success 'multivar replace' '
285 git config nextsection.nonewline "wow3" "wow$" &&
286 test_cmp expect .git/config
289 test_expect_success 'ambiguous unset' '
290 test_must_fail git config --unset nextsection.nonewline
293 test_expect_success 'invalid unset' '
294 test_must_fail git config --unset somesection.nonewline
297 cat > expect << EOF
298 [beta] ; silly comment # another comment
299 noIndent= sillyValue ; 'nother silly comment
301 # empty line
302 ; comment
303 [nextSection]
304 NoNewLine = wow2 for me
307 test_expect_success 'multivar unset' '
308 git config --unset nextsection.nonewline "wow3$" &&
309 test_cmp expect .git/config
312 test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
314 test_expect_success 'correct key' 'git config 123456.a123 987'
316 test_expect_success 'hierarchical section' '
317 git config Version.1.2.3eX.Alpha beta
320 cat > expect << EOF
321 [beta] ; silly comment # another comment
322 noIndent= sillyValue ; 'nother silly comment
324 # empty line
325 ; comment
326 [nextSection]
327 NoNewLine = wow2 for me
328 [123456]
329 a123 = 987
330 [Version "1.2.3eX"]
331 Alpha = beta
334 test_expect_success 'hierarchical section value' '
335 test_cmp expect .git/config
338 cat > expect << EOF
339 beta.noindent=sillyValue
340 nextsection.nonewline=wow2 for me
341 123456.a123=987
342 version.1.2.3eX.alpha=beta
345 test_expect_success 'working --list' '
346 git config --list > output &&
347 test_cmp expect output
349 test_expect_success '--list without repo produces empty output' '
350 git --git-dir=nonexistent config --list >output &&
351 test_must_be_empty output
354 cat > expect << EOF
355 beta.noindent
356 nextsection.nonewline
357 123456.a123
358 version.1.2.3eX.alpha
361 test_expect_success '--name-only --list' '
362 git config --name-only --list >output &&
363 test_cmp expect output
366 cat > expect << EOF
367 beta.noindent sillyValue
368 nextsection.nonewline wow2 for me
371 test_expect_success '--get-regexp' '
372 git config --get-regexp in >output &&
373 test_cmp expect output
376 cat > expect << EOF
377 beta.noindent
378 nextsection.nonewline
381 test_expect_success '--name-only --get-regexp' '
382 git config --name-only --get-regexp in >output &&
383 test_cmp expect output
386 cat > expect << EOF
387 wow2 for me
388 wow4 for you
391 test_expect_success '--add' '
392 git config --add nextsection.nonewline "wow4 for you" &&
393 git config --get-all nextsection.nonewline > output &&
394 test_cmp expect output
397 cat > .git/config << EOF
398 [novalue]
399 variable
400 [emptyvalue]
401 variable =
404 test_expect_success 'get variable with no value' '
405 git config --get novalue.variable ^$
408 test_expect_success 'get variable with empty value' '
409 git config --get emptyvalue.variable ^$
412 echo novalue.variable > expect
414 test_expect_success 'get-regexp variable with no value' '
415 git config --get-regexp novalue > output &&
416 test_cmp expect output
419 echo 'novalue.variable true' > expect
421 test_expect_success 'get-regexp --bool variable with no value' '
422 git config --bool --get-regexp novalue > output &&
423 test_cmp expect output
426 echo 'emptyvalue.variable ' > expect
428 test_expect_success 'get-regexp variable with empty value' '
429 git config --get-regexp emptyvalue > output &&
430 test_cmp expect output
433 echo true > expect
435 test_expect_success 'get bool variable with no value' '
436 git config --bool novalue.variable > output &&
437 test_cmp expect output
440 echo false > expect
442 test_expect_success 'get bool variable with empty value' '
443 git config --bool emptyvalue.variable > output &&
444 test_cmp expect output
447 test_expect_success 'no arguments, but no crash' '
448 test_must_fail git config >output 2>&1 &&
449 test_i18ngrep usage output
452 cat > .git/config << EOF
453 [a.b]
454 c = d
457 cat > expect << EOF
458 [a.b]
459 c = d
461 x = y
464 test_expect_success 'new section is partial match of another' '
465 git config a.x y &&
466 test_cmp expect .git/config
469 cat > expect << EOF
470 [a.b]
471 c = d
473 x = y
474 b = c
476 x = y
479 test_expect_success 'new variable inserts into proper section' '
480 git config b.x y &&
481 git config a.b c &&
482 test_cmp expect .git/config
485 test_expect_success 'alternative --file (non-existing file should fail)' '
486 test_must_fail git config --file non-existing-config -l
489 cat > other-config << EOF
490 [ein]
491 bahn = strasse
494 cat > expect << EOF
495 ein.bahn=strasse
498 test_expect_success 'alternative GIT_CONFIG' '
499 GIT_CONFIG=other-config git config --list >output &&
500 test_cmp expect output
503 test_expect_success 'alternative GIT_CONFIG (--file)' '
504 git config --file other-config --list >output &&
505 test_cmp expect output
508 test_expect_success 'alternative GIT_CONFIG (--file=-)' '
509 git config --file - --list <other-config >output &&
510 test_cmp expect output
513 test_expect_success 'setting a value in stdin is an error' '
514 test_must_fail git config --file - some.value foo
517 test_expect_success 'editing stdin is an error' '
518 test_must_fail git config --file - --edit
521 test_expect_success 'refer config from subdirectory' '
522 mkdir x &&
524 cd x &&
525 echo strasse >expect &&
526 git config --get --file ../other-config ein.bahn >actual &&
527 test_cmp expect actual
532 test_expect_success 'refer config from subdirectory via --file' '
534 cd x &&
535 git config --file=../other-config --get ein.bahn >actual &&
536 test_cmp expect actual
540 cat > expect << EOF
541 [ein]
542 bahn = strasse
543 [anwohner]
544 park = ausweis
547 test_expect_success '--set in alternative file' '
548 git config --file=other-config anwohner.park ausweis &&
549 test_cmp expect other-config
552 cat > .git/config << EOF
553 # Hallo
554 #Bello
555 [branch "eins"]
556 x = 1
557 [branch.eins]
558 y = 1
559 [branch "1 234 blabl/a"]
560 weird
563 test_expect_success 'rename section' '
564 git config --rename-section branch.eins branch.zwei
567 cat > expect << EOF
568 # Hallo
569 #Bello
570 [branch "zwei"]
571 x = 1
572 [branch "zwei"]
573 y = 1
574 [branch "1 234 blabl/a"]
575 weird
578 test_expect_success 'rename succeeded' '
579 test_cmp expect .git/config
582 test_expect_success 'rename non-existing section' '
583 test_must_fail git config --rename-section \
584 branch."world domination" branch.drei
587 test_expect_success 'rename succeeded' '
588 test_cmp expect .git/config
591 test_expect_success 'rename another section' '
592 git config --rename-section branch."1 234 blabl/a" branch.drei
595 cat > expect << EOF
596 # Hallo
597 #Bello
598 [branch "zwei"]
599 x = 1
600 [branch "zwei"]
601 y = 1
602 [branch "drei"]
603 weird
606 test_expect_success 'rename succeeded' '
607 test_cmp expect .git/config
610 cat >> .git/config << EOF
611 [branch "vier"] z = 1
614 test_expect_success 'rename a section with a var on the same line' '
615 git config --rename-section branch.vier branch.zwei
618 cat > expect << EOF
619 # Hallo
620 #Bello
621 [branch "zwei"]
622 x = 1
623 [branch "zwei"]
624 y = 1
625 [branch "drei"]
626 weird
627 [branch "zwei"]
628 z = 1
631 test_expect_success 'rename succeeded' '
632 test_cmp expect .git/config
635 test_expect_success 'renaming empty section name is rejected' '
636 test_must_fail git config --rename-section branch.zwei ""
639 test_expect_success 'renaming to bogus section is rejected' '
640 test_must_fail git config --rename-section branch.zwei "bogus name"
643 cat >> .git/config << EOF
644 [branch "zwei"] a = 1 [branch "vier"]
647 test_expect_success 'remove section' '
648 git config --remove-section branch.zwei
651 cat > expect << EOF
652 # Hallo
653 #Bello
654 [branch "drei"]
655 weird
658 test_expect_success 'section was removed properly' '
659 test_cmp expect .git/config
662 cat > expect << EOF
663 [gitcvs]
664 enabled = true
665 dbname = %Ggitcvs2.%a.%m.sqlite
666 [gitcvs "ext"]
667 dbname = %Ggitcvs1.%a.%m.sqlite
670 test_expect_success 'section ending' '
671 rm -f .git/config &&
672 git config gitcvs.enabled true &&
673 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
674 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
675 test_cmp expect .git/config
679 test_expect_success numbers '
680 git config kilo.gram 1k &&
681 git config mega.ton 1m &&
682 echo 1024 >expect &&
683 echo 1048576 >>expect &&
684 git config --int --get kilo.gram >actual &&
685 git config --int --get mega.ton >>actual &&
686 test_cmp expect actual
689 test_expect_success '--int is at least 64 bits' '
690 git config giga.watts 121g &&
691 echo 129922760704 >expect &&
692 git config --int --get giga.watts >actual &&
693 test_cmp expect actual
696 test_expect_success 'invalid unit' '
697 git config aninvalid.unit "1auto" &&
698 echo 1auto >expect &&
699 git config aninvalid.unit >actual &&
700 test_cmp expect actual &&
701 test_must_fail git config --int --get aninvalid.unit 2>actual &&
702 test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
705 test_expect_success 'line number is reported correctly' '
706 printf "[bool]\n\tvar\n" >invalid &&
707 test_must_fail git config -f invalid --path bool.var 2>actual &&
708 test_i18ngrep "line 2" actual
711 test_expect_success 'invalid stdin config' '
712 echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
713 test_i18ngrep "bad config line 1 in standard input" output
716 cat > expect << EOF
717 true
718 false
719 true
720 false
721 true
722 false
723 true
724 false
727 test_expect_success bool '
729 git config bool.true1 01 &&
730 git config bool.true2 -1 &&
731 git config bool.true3 YeS &&
732 git config bool.true4 true &&
733 git config bool.false1 000 &&
734 git config bool.false2 "" &&
735 git config bool.false3 nO &&
736 git config bool.false4 FALSE &&
737 rm -f result &&
738 for i in 1 2 3 4
740 git config --bool --get bool.true$i >>result
741 git config --bool --get bool.false$i >>result
742 done &&
743 test_cmp expect result'
745 test_expect_success 'invalid bool (--get)' '
747 git config bool.nobool foobar &&
748 test_must_fail git config --bool --get bool.nobool'
750 test_expect_success 'invalid bool (set)' '
752 test_must_fail git config --bool bool.nobool foobar'
754 cat > expect <<\EOF
755 [bool]
756 true1 = true
757 true2 = true
758 true3 = true
759 true4 = true
760 false1 = false
761 false2 = false
762 false3 = false
763 false4 = false
766 test_expect_success 'set --bool' '
768 rm -f .git/config &&
769 git config --bool bool.true1 01 &&
770 git config --bool bool.true2 -1 &&
771 git config --bool bool.true3 YeS &&
772 git config --bool bool.true4 true &&
773 git config --bool bool.false1 000 &&
774 git config --bool bool.false2 "" &&
775 git config --bool bool.false3 nO &&
776 git config --bool bool.false4 FALSE &&
777 test_cmp expect .git/config'
779 cat > expect <<\EOF
780 [int]
781 val1 = 1
782 val2 = -1
783 val3 = 5242880
786 test_expect_success 'set --int' '
788 rm -f .git/config &&
789 git config --int int.val1 01 &&
790 git config --int int.val2 -1 &&
791 git config --int int.val3 5m &&
792 test_cmp expect .git/config
795 test_expect_success 'get --bool-or-int' '
796 cat >.git/config <<-\EOF &&
797 [bool]
798 true1
799 true2 = true
800 false = false
801 [int]
802 int1 = 0
803 int2 = 1
804 int3 = -1
806 cat >expect <<-\EOF &&
807 true
808 true
809 false
815 git config --bool-or-int bool.true1 &&
816 git config --bool-or-int bool.true2 &&
817 git config --bool-or-int bool.false &&
818 git config --bool-or-int int.int1 &&
819 git config --bool-or-int int.int2 &&
820 git config --bool-or-int int.int3
821 } >actual &&
822 test_cmp expect actual
825 cat >expect <<\EOF
826 [bool]
827 true1 = true
828 false1 = false
829 true2 = true
830 false2 = false
831 [int]
832 int1 = 0
833 int2 = 1
834 int3 = -1
837 test_expect_success 'set --bool-or-int' '
838 rm -f .git/config &&
839 git config --bool-or-int bool.true1 true &&
840 git config --bool-or-int bool.false1 false &&
841 git config --bool-or-int bool.true2 yes &&
842 git config --bool-or-int bool.false2 no &&
843 git config --bool-or-int int.int1 0 &&
844 git config --bool-or-int int.int2 1 &&
845 git config --bool-or-int int.int3 -1 &&
846 test_cmp expect .git/config
849 cat >expect <<\EOF
850 [path]
851 home = ~/
852 normal = /dev/null
853 trailingtilde = foo~
856 test_expect_success !MINGW 'set --path' '
857 rm -f .git/config &&
858 git config --path path.home "~/" &&
859 git config --path path.normal "/dev/null" &&
860 git config --path path.trailingtilde "foo~" &&
861 test_cmp expect .git/config'
863 if test_have_prereq !MINGW && test "${HOME+set}"
864 then
865 test_set_prereq HOMEVAR
868 cat >expect <<EOF
869 $HOME/
870 /dev/null
871 foo~
874 test_expect_success HOMEVAR 'get --path' '
875 git config --get --path path.home > result &&
876 git config --get --path path.normal >> result &&
877 git config --get --path path.trailingtilde >> result &&
878 test_cmp expect result
881 cat >expect <<\EOF
882 /dev/null
883 foo~
886 test_expect_success !MINGW 'get --path copes with unset $HOME' '
888 unset HOME;
889 test_must_fail git config --get --path path.home \
890 >result 2>msg &&
891 git config --get --path path.normal >>result &&
892 git config --get --path path.trailingtilde >>result
893 ) &&
894 test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
895 test_cmp expect result
898 test_expect_success 'get --path barfs on boolean variable' '
899 echo "[path]bool" >.git/config &&
900 test_must_fail git config --get --path path.bool
903 test_expect_success 'get --expiry-date' '
904 rel="3.weeks.5.days.00:00" &&
905 rel_out="$rel ->" &&
906 cat >.git/config <<-\EOF &&
907 [date]
908 valid1 = "3.weeks.5.days 00:00"
909 valid2 = "Fri Jun 4 15:46:55 2010"
910 valid3 = "2017/11/11 11:11:11PM"
911 valid4 = "2017/11/10 09:08:07 PM"
912 valid5 = "never"
913 invalid1 = "abc"
915 cat >expect <<-EOF &&
916 $(test-tool date timestamp $rel)
917 1275666415
918 1510441871
919 1510348087
923 echo "$rel_out $(git config --expiry-date date.valid1)"
924 git config --expiry-date date.valid2 &&
925 git config --expiry-date date.valid3 &&
926 git config --expiry-date date.valid4 &&
927 git config --expiry-date date.valid5
928 } >actual &&
929 test_cmp expect actual &&
930 test_must_fail git config --expiry-date date.invalid1
933 test_expect_success 'get --type=color' '
934 rm .git/config &&
935 git config foo.color "red" &&
936 git config --get --type=color foo.color >actual.raw &&
937 test_decode_color <actual.raw >actual &&
938 echo "<RED>" >expect &&
939 test_cmp expect actual
942 cat >expect << EOF
943 [foo]
944 color = red
947 test_expect_success 'set --type=color' '
948 rm .git/config &&
949 git config --type=color foo.color "red" &&
950 test_cmp expect .git/config
953 test_expect_success 'get --type=color barfs on non-color' '
954 echo "[foo]bar=not-a-color" >.git/config &&
955 test_must_fail git config --get --type=color foo.bar
958 test_expect_success 'set --type=color barfs on non-color' '
959 test_must_fail git config --type=color foo.color "not-a-color" 2>error &&
960 test_i18ngrep "cannot parse color" error
963 cat > expect << EOF
964 [quote]
965 leading = " test"
966 ending = "test "
967 semicolon = "test;test"
968 hash = "test#test"
970 test_expect_success 'quoting' '
971 rm -f .git/config &&
972 git config quote.leading " test" &&
973 git config quote.ending "test " &&
974 git config quote.semicolon "test;test" &&
975 git config quote.hash "test#test" &&
976 test_cmp expect .git/config
979 test_expect_success 'key with newline' '
980 test_must_fail git config "key.with
981 newline" 123'
983 test_expect_success 'value with newline' 'git config key.sub value.with\\\
984 newline'
986 cat > .git/config <<\EOF
987 [section]
988 ; comment \
989 continued = cont\
990 inued
991 noncont = not continued ; \
992 quotecont = "cont;\
993 inued"
996 cat > expect <<\EOF
997 section.continued=continued
998 section.noncont=not continued
999 section.quotecont=cont;inued
1002 test_expect_success 'value continued on next line' '
1003 git config --list > result &&
1004 test_cmp result expect
1007 cat > .git/config <<\EOF
1008 [section "sub=section"]
1009 val1 = foo=bar
1010 val2 = foo\nbar
1011 val3 = \n\n
1012 val4 =
1013 val5
1016 cat > expect <<\EOF
1017 section.sub=section.val1
1018 foo=barQsection.sub=section.val2
1020 barQsection.sub=section.val3
1023 Qsection.sub=section.val4
1024 Qsection.sub=section.val5Q
1026 test_expect_success '--null --list' '
1027 git config --null --list >result.raw &&
1028 nul_to_q <result.raw >result &&
1029 echo >>result &&
1030 test_cmp expect result
1033 test_expect_success '--null --get-regexp' '
1034 git config --null --get-regexp "val[0-9]" >result.raw &&
1035 nul_to_q <result.raw >result &&
1036 echo >>result &&
1037 test_cmp expect result
1040 test_expect_success 'inner whitespace kept verbatim' '
1041 git config section.val "foo bar" &&
1042 echo "foo bar" >expect &&
1043 git config section.val >actual &&
1044 test_cmp expect actual
1047 test_expect_success SYMLINKS 'symlinked configuration' '
1048 ln -s notyet myconfig &&
1049 git config --file=myconfig test.frotz nitfol &&
1050 test -h myconfig &&
1051 test -f notyet &&
1052 test "z$(git config --file=notyet test.frotz)" = znitfol &&
1053 git config --file=myconfig test.xyzzy rezrov &&
1054 test -h myconfig &&
1055 test -f notyet &&
1056 cat >expect <<-\EOF &&
1057 nitfol
1058 rezrov
1061 git config --file=notyet test.frotz &&
1062 git config --file=notyet test.xyzzy
1063 } >actual &&
1064 test_cmp expect actual
1067 test_expect_success 'nonexistent configuration' '
1068 test_must_fail git config --file=doesnotexist --list &&
1069 test_must_fail git config --file=doesnotexist test.xyzzy
1072 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
1073 ln -s doesnotexist linktonada &&
1074 ln -s linktonada linktolinktonada &&
1075 test_must_fail git config --file=linktonada --list &&
1076 test_must_fail git config --file=linktolinktonada --list
1079 test_expect_success 'check split_cmdline return' "
1080 git config alias.split-cmdline-fix 'echo \"' &&
1081 test_must_fail git split-cmdline-fix &&
1082 echo foo > foo &&
1083 git add foo &&
1084 git commit -m 'initial commit' &&
1085 git config branch.master.mergeoptions 'echo \"' &&
1086 test_must_fail git merge master
1089 test_expect_success 'git -c "key=value" support' '
1090 cat >expect <<-\EOF &&
1091 value
1092 value
1093 true
1096 git -c core.name=value config core.name &&
1097 git -c foo.CamelCase=value config foo.camelcase &&
1098 git -c foo.flag config --bool foo.flag
1099 } >actual &&
1100 test_cmp expect actual &&
1101 test_must_fail git -c name=value config core.name
1104 # We just need a type-specifier here that cares about the
1105 # distinction internally between a NULL boolean and a real
1106 # string (because most of git's internal parsers do care).
1107 # Using "--path" works, but we do not otherwise care about
1108 # its semantics.
1109 test_expect_success 'git -c can represent empty string' '
1110 echo >expect &&
1111 git -c foo.empty= config --path foo.empty >actual &&
1112 test_cmp expect actual
1115 test_expect_success 'key sanity-checking' '
1116 test_must_fail git config foo=bar &&
1117 test_must_fail git config foo=.bar &&
1118 test_must_fail git config foo.ba=r &&
1119 test_must_fail git config foo.1bar &&
1120 test_must_fail git config foo."ba
1121 z".bar &&
1122 test_must_fail git config . false &&
1123 test_must_fail git config .foo false &&
1124 test_must_fail git config foo. false &&
1125 test_must_fail git config .foo. false &&
1126 git config foo.bar true &&
1127 git config foo."ba =z".bar false
1130 test_expect_success 'git -c works with aliases of builtins' '
1131 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
1132 echo bar >expect &&
1133 git checkconfig >actual &&
1134 test_cmp expect actual
1137 test_expect_success 'aliases can be CamelCased' '
1138 test_config alias.CamelCased "rev-parse HEAD" &&
1139 git CamelCased >out &&
1140 git rev-parse HEAD >expect &&
1141 test_cmp expect out
1144 test_expect_success 'git -c does not split values on equals' '
1145 echo "value with = in it" >expect &&
1146 git -c core.foo="value with = in it" config core.foo >actual &&
1147 test_cmp expect actual
1150 test_expect_success 'git -c dies on bogus config' '
1151 test_must_fail git -c core.bare=foo rev-parse
1154 test_expect_success 'git -c complains about empty key' '
1155 test_must_fail git -c "=foo" rev-parse
1158 test_expect_success 'git -c complains about empty key and value' '
1159 test_must_fail git -c "" rev-parse
1162 test_expect_success 'multiple git -c appends config' '
1163 test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
1164 cat >expect <<-\EOF &&
1165 x.one 1
1166 x.two 2
1168 git -c x.one=1 x >actual &&
1169 test_cmp expect actual
1172 test_expect_success 'last one wins: two level vars' '
1174 # sec.var and sec.VAR are the same variable, as the first
1175 # and the last level of a configuration variable name is
1176 # case insensitive.
1178 echo VAL >expect &&
1180 git -c sec.var=val -c sec.VAR=VAL config --get sec.var >actual &&
1181 test_cmp expect actual &&
1182 git -c SEC.var=val -c sec.var=VAL config --get sec.var >actual &&
1183 test_cmp expect actual &&
1185 git -c sec.var=val -c sec.VAR=VAL config --get SEC.var >actual &&
1186 test_cmp expect actual &&
1187 git -c SEC.var=val -c sec.var=VAL config --get sec.VAR >actual &&
1188 test_cmp expect actual
1191 test_expect_success 'last one wins: three level vars' '
1193 # v.a.r and v.A.r are not the same variable, as the middle
1194 # level of a three-level configuration variable name is
1195 # case sensitive.
1197 echo val >expect &&
1198 git -c v.a.r=val -c v.A.r=VAL config --get v.a.r >actual &&
1199 test_cmp expect actual &&
1200 git -c v.a.r=val -c v.A.r=VAL config --get V.a.R >actual &&
1201 test_cmp expect actual &&
1203 # v.a.r and V.a.R are the same variable, as the first
1204 # and the last level of a configuration variable name is
1205 # case insensitive.
1207 echo VAL >expect &&
1208 git -c v.a.r=val -c v.a.R=VAL config --get v.a.r >actual &&
1209 test_cmp expect actual &&
1210 git -c v.a.r=val -c V.a.r=VAL config --get v.a.r >actual &&
1211 test_cmp expect actual &&
1212 git -c v.a.r=val -c v.a.R=VAL config --get V.a.R >actual &&
1213 test_cmp expect actual &&
1214 git -c v.a.r=val -c V.a.r=VAL config --get V.a.R >actual &&
1215 test_cmp expect actual
1218 for VAR in a .a a. a.0b a."b c". a."b c".0d
1220 test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" '
1221 test_must_fail git -c "$VAR=VAL" config -l
1223 done
1225 for VAR in a.b a."b c".d
1227 test_expect_success "git -c $VAR=VAL works with valid '$VAR'" '
1228 echo VAL >expect &&
1229 git -c "$VAR=VAL" config --get "$VAR" >actual &&
1230 test_cmp expect actual
1232 done
1234 test_expect_success 'git -c is not confused by empty environment' '
1235 GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
1238 sq="'"
1239 test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
1240 cat >expect <<-\EOF &&
1241 env.one one
1242 env.two two
1244 GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq} ${sq}env.two=two${sq}" \
1245 git config --get-regexp "env.*" >actual &&
1246 test_cmp expect actual &&
1248 cat >expect <<-EOF &&
1249 env.one one${sq}
1250 env.two two
1252 GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq$sq$sq ${sq}env.two=two${sq}" \
1253 git config --get-regexp "env.*" >actual &&
1254 test_cmp expect actual &&
1256 test_must_fail env \
1257 GIT_CONFIG_PARAMETERS="${sq}env.one=one${sq}\\$sq ${sq}env.two=two${sq}" \
1258 git config --get-regexp "env.*"
1261 test_expect_success 'git config --edit works' '
1262 git config -f tmp test.value no &&
1263 echo test.value=yes >expect &&
1264 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1265 git config -f tmp --list >actual &&
1266 test_cmp expect actual
1269 test_expect_success 'git config --edit respects core.editor' '
1270 git config -f tmp test.value no &&
1271 echo test.value=yes >expect &&
1272 test_config core.editor "echo [test]value=yes >" &&
1273 git config -f tmp --edit &&
1274 git config -f tmp --list >actual &&
1275 test_cmp expect actual
1278 # malformed configuration files
1279 test_expect_success 'barf on syntax error' '
1280 cat >.git/config <<-\EOF &&
1281 # broken section line
1282 [section]
1283 key garbage
1285 test_must_fail git config --get section.key >actual 2>error &&
1286 test_i18ngrep " line 3 " error
1289 test_expect_success 'barf on incomplete section header' '
1290 cat >.git/config <<-\EOF &&
1291 # broken section line
1292 [section
1293 key = value
1295 test_must_fail git config --get section.key >actual 2>error &&
1296 test_i18ngrep " line 2 " error
1299 test_expect_success 'barf on incomplete string' '
1300 cat >.git/config <<-\EOF &&
1301 # broken section line
1302 [section]
1303 key = "value string
1305 test_must_fail git config --get section.key >actual 2>error &&
1306 test_i18ngrep " line 3 " error
1309 test_expect_success 'urlmatch' '
1310 cat >.git/config <<-\EOF &&
1311 [http]
1312 sslVerify
1313 [http "https://weak.example.com"]
1314 sslVerify = false
1315 cookieFile = /tmp/cookie.txt
1318 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1319 test_must_be_empty actual &&
1321 echo true >expect &&
1322 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
1323 test_cmp expect actual &&
1325 echo false >expect &&
1326 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual &&
1327 test_cmp expect actual &&
1330 echo http.cookiefile /tmp/cookie.txt &&
1331 echo http.sslverify false
1332 } >expect &&
1333 git config --get-urlmatch HTTP https://weak.example.com >actual &&
1334 test_cmp expect actual
1337 test_expect_success 'urlmatch favors more specific URLs' '
1338 cat >.git/config <<-\EOF &&
1339 [http "https://example.com/"]
1340 cookieFile = /tmp/root.txt
1341 [http "https://example.com/subdirectory"]
1342 cookieFile = /tmp/subdirectory.txt
1343 [http "https://user@example.com/"]
1344 cookieFile = /tmp/user.txt
1345 [http "https://averylonguser@example.com/"]
1346 cookieFile = /tmp/averylonguser.txt
1347 [http "https://preceding.example.com"]
1348 cookieFile = /tmp/preceding.txt
1349 [http "https://*.example.com"]
1350 cookieFile = /tmp/wildcard.txt
1351 [http "https://*.example.com/wildcardwithsubdomain"]
1352 cookieFile = /tmp/wildcardwithsubdomain.txt
1353 [http "https://trailing.example.com"]
1354 cookieFile = /tmp/trailing.txt
1355 [http "https://user@*.example.com/"]
1356 cookieFile = /tmp/wildcardwithuser.txt
1357 [http "https://sub.example.com/"]
1358 cookieFile = /tmp/sub.txt
1361 echo http.cookiefile /tmp/root.txt >expect &&
1362 git config --get-urlmatch HTTP https://example.com >actual &&
1363 test_cmp expect actual &&
1365 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1366 git config --get-urlmatch HTTP https://example.com/subdirectory >actual &&
1367 test_cmp expect actual &&
1369 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1370 git config --get-urlmatch HTTP https://example.com/subdirectory/nested >actual &&
1371 test_cmp expect actual &&
1373 echo http.cookiefile /tmp/user.txt >expect &&
1374 git config --get-urlmatch HTTP https://user@example.com/ >actual &&
1375 test_cmp expect actual &&
1377 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1378 git config --get-urlmatch HTTP https://averylonguser@example.com/subdirectory >actual &&
1379 test_cmp expect actual &&
1381 echo http.cookiefile /tmp/preceding.txt >expect &&
1382 git config --get-urlmatch HTTP https://preceding.example.com >actual &&
1383 test_cmp expect actual &&
1385 echo http.cookiefile /tmp/wildcard.txt >expect &&
1386 git config --get-urlmatch HTTP https://wildcard.example.com >actual &&
1387 test_cmp expect actual &&
1389 echo http.cookiefile /tmp/sub.txt >expect &&
1390 git config --get-urlmatch HTTP https://sub.example.com/wildcardwithsubdomain >actual &&
1391 test_cmp expect actual &&
1393 echo http.cookiefile /tmp/trailing.txt >expect &&
1394 git config --get-urlmatch HTTP https://trailing.example.com >actual &&
1395 test_cmp expect actual &&
1397 echo http.cookiefile /tmp/sub.txt >expect &&
1398 git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
1399 test_cmp expect actual
1402 test_expect_success 'urlmatch with wildcard' '
1403 cat >.git/config <<-\EOF &&
1404 [http]
1405 sslVerify
1406 [http "https://*.example.com"]
1407 sslVerify = false
1408 cookieFile = /tmp/cookie.txt
1411 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1412 test_must_be_empty actual &&
1414 echo true >expect &&
1415 git config --bool --get-urlmatch http.SSLverify https://example.com >actual &&
1416 test_cmp expect actual &&
1418 echo true >expect &&
1419 git config --bool --get-urlmatch http.SSLverify https://good-example.com >actual &&
1420 test_cmp expect actual &&
1422 echo true >expect &&
1423 git config --bool --get-urlmatch http.sslverify https://deep.nested.example.com >actual &&
1424 test_cmp expect actual &&
1426 echo false >expect &&
1427 git config --bool --get-urlmatch http.sslverify https://good.example.com >actual &&
1428 test_cmp expect actual &&
1431 echo http.cookiefile /tmp/cookie.txt &&
1432 echo http.sslverify false
1433 } >expect &&
1434 git config --get-urlmatch HTTP https://good.example.com >actual &&
1435 test_cmp expect actual &&
1437 echo http.sslverify >expect &&
1438 git config --get-urlmatch HTTP https://more.example.com.au >actual &&
1439 test_cmp expect actual
1442 # good section hygiene
1443 test_expect_success '--unset last key removes section (except if commented)' '
1444 cat >.git/config <<-\EOF &&
1445 # some generic comment on the configuration file itself
1446 # a comment specific to this "section" section.
1447 [section]
1448 # some intervening lines
1449 # that should also be dropped
1451 key = value
1452 # please be careful when you update the above variable
1455 cat >expect <<-\EOF &&
1456 # some generic comment on the configuration file itself
1457 # a comment specific to this "section" section.
1458 [section]
1459 # some intervening lines
1460 # that should also be dropped
1462 # please be careful when you update the above variable
1465 git config --unset section.key &&
1466 test_cmp expect .git/config &&
1468 cat >.git/config <<-\EOF &&
1469 [section]
1470 key = value
1471 [next-section]
1474 cat >expect <<-\EOF &&
1475 [next-section]
1478 git config --unset section.key &&
1479 test_cmp expect .git/config &&
1481 q_to_tab >.git/config <<-\EOF &&
1482 [one]
1483 Qkey = "multiline \
1484 QQ# with comment"
1485 [two]
1486 key = true
1488 git config --unset two.key &&
1489 ! grep two .git/config &&
1491 q_to_tab >.git/config <<-\EOF &&
1492 [one]
1493 Qkey = "multiline \
1494 QQ# with comment"
1495 [one]
1496 key = true
1498 git config --unset-all one.key &&
1499 test_line_count = 0 .git/config &&
1501 q_to_tab >.git/config <<-\EOF &&
1502 [one]
1503 Qkey = true
1504 Q# a comment not at the start
1505 [two]
1506 Qkey = true
1508 git config --unset two.key &&
1509 grep two .git/config &&
1511 q_to_tab >.git/config <<-\EOF &&
1512 [one]
1513 Qkey = not [two "subsection"]
1514 [two "subsection"]
1515 [two "subsection"]
1516 Qkey = true
1517 [TWO "subsection"]
1518 [one]
1520 git config --unset two.subsection.key &&
1521 test "not [two subsection]" = "$(git config one.key)" &&
1522 test_line_count = 3 .git/config
1525 test_expect_success '--unset-all removes section if empty & uncommented' '
1526 cat >.git/config <<-\EOF &&
1527 [section]
1528 key = value1
1529 key = value2
1532 git config --unset-all section.key &&
1533 test_line_count = 0 .git/config
1536 test_expect_success 'adding a key into an empty section reuses header' '
1537 cat >.git/config <<-\EOF &&
1538 [section]
1541 q_to_tab >expect <<-\EOF &&
1542 [section]
1543 Qkey = value
1546 git config section.key value &&
1547 test_cmp expect .git/config
1550 test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
1551 chmod 0600 .git/config &&
1552 git config imap.pass Hunter2 &&
1553 perl -e \
1554 "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
1555 git config --rename-section imap pop &&
1556 perl -e \
1557 "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
1560 ! test_have_prereq MINGW ||
1561 HOME="$(pwd)" # convert to Windows path
1563 test_expect_success 'set up --show-origin tests' '
1564 INCLUDE_DIR="$HOME/include" &&
1565 mkdir -p "$INCLUDE_DIR" &&
1566 cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
1567 [user]
1568 absolute = include
1570 cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
1571 [user]
1572 relative = include
1574 cat >"$HOME"/.gitconfig <<-EOF &&
1575 [user]
1576 global = true
1577 override = global
1578 [include]
1579 path = "$INCLUDE_DIR/absolute.include"
1581 cat >.git/config <<-\EOF
1582 [user]
1583 local = true
1584 override = local
1585 [include]
1586 path = ../include/relative.include
1590 test_expect_success '--show-origin with --list' '
1591 cat >expect <<-EOF &&
1592 file:$HOME/.gitconfig user.global=true
1593 file:$HOME/.gitconfig user.override=global
1594 file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
1595 file:$INCLUDE_DIR/absolute.include user.absolute=include
1596 file:.git/config user.local=true
1597 file:.git/config user.override=local
1598 file:.git/config include.path=../include/relative.include
1599 file:.git/../include/relative.include user.relative=include
1600 command line: user.cmdline=true
1602 git -c user.cmdline=true config --list --show-origin >output &&
1603 test_cmp expect output
1606 test_expect_success '--show-origin with --list --null' '
1607 cat >expect <<-EOF &&
1608 file:$HOME/.gitconfigQuser.global
1609 trueQfile:$HOME/.gitconfigQuser.override
1610 globalQfile:$HOME/.gitconfigQinclude.path
1611 $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
1612 includeQfile:.git/configQuser.local
1613 trueQfile:.git/configQuser.override
1614 localQfile:.git/configQinclude.path
1615 ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
1616 includeQcommand line:Quser.cmdline
1617 trueQ
1619 git -c user.cmdline=true config --null --list --show-origin >output.raw &&
1620 nul_to_q <output.raw >output &&
1621 # The here-doc above adds a newline that the --null output would not
1622 # include. Add it here to make the two comparable.
1623 echo >>output &&
1624 test_cmp expect output
1627 test_expect_success '--show-origin with single file' '
1628 cat >expect <<-\EOF &&
1629 file:.git/config user.local=true
1630 file:.git/config user.override=local
1631 file:.git/config include.path=../include/relative.include
1633 git config --local --list --show-origin >output &&
1634 test_cmp expect output
1637 test_expect_success '--show-origin with --get-regexp' '
1638 cat >expect <<-EOF &&
1639 file:$HOME/.gitconfig user.global true
1640 file:.git/config user.local true
1642 git config --show-origin --get-regexp "user\.[g|l].*" >output &&
1643 test_cmp expect output
1646 test_expect_success '--show-origin getting a single key' '
1647 cat >expect <<-\EOF &&
1648 file:.git/config local
1650 git config --show-origin user.override >output &&
1651 test_cmp expect output
1654 test_expect_success 'set up custom config file' '
1655 CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
1656 cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
1657 [user]
1658 custom = true
1662 test_expect_success !MINGW '--show-origin escape special file name characters' '
1663 cat >expect <<-\EOF &&
1664 file:"file\" (dq) and spaces.conf" user.custom=true
1666 git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1667 test_cmp expect output
1670 test_expect_success '--show-origin stdin' '
1671 cat >expect <<-\EOF &&
1672 standard input: user.custom=true
1674 git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
1675 test_cmp expect output
1678 test_expect_success '--show-origin stdin with file include' '
1679 cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
1680 [user]
1681 stdin = include
1683 cat >expect <<-EOF &&
1684 file:$INCLUDE_DIR/stdin.include include
1686 echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
1687 | git config --show-origin --includes --file - user.stdin >output &&
1688 test_cmp expect output
1691 test_expect_success !MINGW '--show-origin blob' '
1692 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
1693 cat >expect <<-EOF &&
1694 blob:$blob user.custom=true
1696 git config --blob=$blob --show-origin --list >output &&
1697 test_cmp expect output
1700 test_expect_success !MINGW '--show-origin blob ref' '
1701 cat >expect <<-\EOF &&
1702 blob:"master:file\" (dq) and spaces.conf" user.custom=true
1704 git add "$CUSTOM_CONFIG_FILE" &&
1705 git commit -m "new config file" &&
1706 git config --blob=master:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1707 test_cmp expect output
1710 test_expect_success '--local requires a repo' '
1711 # we expect 128 to ensure that we do not simply
1712 # fail to find anything and return code "1"
1713 test_expect_code 128 nongit git config --local foo.bar
1716 cat >.git/config <<-\EOF &&
1717 [core]
1718 foo = true
1719 number = 10
1720 big = 1M
1723 test_expect_success 'identical modern --type specifiers are allowed' '
1724 git config --type=int --type=int core.big >actual &&
1725 echo 1048576 >expect &&
1726 test_cmp expect actual
1729 test_expect_success 'identical legacy --type specifiers are allowed' '
1730 git config --int --int core.big >actual &&
1731 echo 1048576 >expect &&
1732 test_cmp expect actual
1735 test_expect_success 'identical mixed --type specifiers are allowed' '
1736 git config --int --type=int core.big >actual &&
1737 echo 1048576 >expect &&
1738 test_cmp expect actual
1741 test_expect_success 'non-identical modern --type specifiers are not allowed' '
1742 test_must_fail git config --type=int --type=bool core.big 2>error &&
1743 test_i18ngrep "only one type at a time" error
1746 test_expect_success 'non-identical legacy --type specifiers are not allowed' '
1747 test_must_fail git config --int --bool core.big 2>error &&
1748 test_i18ngrep "only one type at a time" error
1751 test_expect_success 'non-identical mixed --type specifiers are not allowed' '
1752 test_must_fail git config --type=int --bool core.big 2>error &&
1753 test_i18ngrep "only one type at a time" error
1756 test_expect_success '--type allows valid type specifiers' '
1757 echo "true" >expect &&
1758 git config --type=bool core.foo >actual &&
1759 test_cmp expect actual
1762 test_expect_success '--no-type unsets type specifiers' '
1763 echo "10" >expect &&
1764 git config --type=bool --no-type core.number >actual &&
1765 test_cmp expect actual
1768 test_expect_success 'unset type specifiers may be reset to conflicting ones' '
1769 echo 1048576 >expect &&
1770 git config --type=bool --no-type --type=int core.big >actual &&
1771 test_cmp expect actual
1774 test_expect_success '--type rejects unknown specifiers' '
1775 test_must_fail git config --type=nonsense core.foo 2>error &&
1776 test_i18ngrep "unrecognized --type argument" error
1779 test_expect_success '--replace-all does not invent newlines' '
1780 q_to_tab >.git/config <<-\EOF &&
1781 [abc]key
1782 QkeepSection
1783 [xyz]
1784 Qkey = 1
1785 [abc]
1786 Qkey = a
1788 q_to_tab >expect <<-\EOF &&
1789 [abc]
1790 QkeepSection
1791 [xyz]
1792 Qkey = 1
1793 [abc]
1794 Qkey = b
1796 git config --replace-all abc.key b &&
1797 test_cmp .git/config expect
1800 test_done