git-config: document accidental multi-line setting in deprecated syntax
[git.git] / t / t1300-config.sh
blob77c5899d0002dcdca04611974271bf49e35e08b8
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 cat > expect << EOF
352 test_expect_success '--list without repo produces empty output' '
353 git --git-dir=nonexistent config --list >output &&
354 test_cmp expect output
357 cat > expect << EOF
358 beta.noindent
359 nextsection.nonewline
360 123456.a123
361 version.1.2.3eX.alpha
364 test_expect_success '--name-only --list' '
365 git config --name-only --list >output &&
366 test_cmp expect output
369 cat > expect << EOF
370 beta.noindent sillyValue
371 nextsection.nonewline wow2 for me
374 test_expect_success '--get-regexp' '
375 git config --get-regexp in >output &&
376 test_cmp expect output
379 cat > expect << EOF
380 beta.noindent
381 nextsection.nonewline
384 test_expect_success '--name-only --get-regexp' '
385 git config --name-only --get-regexp in >output &&
386 test_cmp expect output
389 cat > expect << EOF
390 wow2 for me
391 wow4 for you
394 test_expect_success '--add' '
395 git config --add nextsection.nonewline "wow4 for you" &&
396 git config --get-all nextsection.nonewline > output &&
397 test_cmp expect output
400 cat > .git/config << EOF
401 [novalue]
402 variable
403 [emptyvalue]
404 variable =
407 test_expect_success 'get variable with no value' '
408 git config --get novalue.variable ^$
411 test_expect_success 'get variable with empty value' '
412 git config --get emptyvalue.variable ^$
415 echo novalue.variable > expect
417 test_expect_success 'get-regexp variable with no value' '
418 git config --get-regexp novalue > output &&
419 test_cmp expect output
422 echo 'novalue.variable true' > expect
424 test_expect_success 'get-regexp --bool variable with no value' '
425 git config --bool --get-regexp novalue > output &&
426 test_cmp expect output
429 echo 'emptyvalue.variable ' > expect
431 test_expect_success 'get-regexp variable with empty value' '
432 git config --get-regexp emptyvalue > output &&
433 test_cmp expect output
436 echo true > expect
438 test_expect_success 'get bool variable with no value' '
439 git config --bool novalue.variable > output &&
440 test_cmp expect output
443 echo false > expect
445 test_expect_success 'get bool variable with empty value' '
446 git config --bool emptyvalue.variable > output &&
447 test_cmp expect output
450 test_expect_success 'no arguments, but no crash' '
451 test_must_fail git config >output 2>&1 &&
452 test_i18ngrep usage output
455 cat > .git/config << EOF
456 [a.b]
457 c = d
460 cat > expect << EOF
461 [a.b]
462 c = d
464 x = y
467 test_expect_success 'new section is partial match of another' '
468 git config a.x y &&
469 test_cmp expect .git/config
472 cat > expect << EOF
473 [a.b]
474 c = d
476 x = y
477 b = c
479 x = y
482 test_expect_success 'new variable inserts into proper section' '
483 git config b.x y &&
484 git config a.b c &&
485 test_cmp expect .git/config
488 test_expect_success 'alternative --file (non-existing file should fail)' '
489 test_must_fail git config --file non-existing-config -l
492 cat > other-config << EOF
493 [ein]
494 bahn = strasse
497 cat > expect << EOF
498 ein.bahn=strasse
501 test_expect_success 'alternative GIT_CONFIG' '
502 GIT_CONFIG=other-config git config --list >output &&
503 test_cmp expect output
506 test_expect_success 'alternative GIT_CONFIG (--file)' '
507 git config --file other-config --list >output &&
508 test_cmp expect output
511 test_expect_success 'alternative GIT_CONFIG (--file=-)' '
512 git config --file - --list <other-config >output &&
513 test_cmp expect output
516 test_expect_success 'setting a value in stdin is an error' '
517 test_must_fail git config --file - some.value foo
520 test_expect_success 'editing stdin is an error' '
521 test_must_fail git config --file - --edit
524 test_expect_success 'refer config from subdirectory' '
525 mkdir x &&
527 cd x &&
528 echo strasse >expect &&
529 git config --get --file ../other-config ein.bahn >actual &&
530 test_cmp expect actual
535 test_expect_success 'refer config from subdirectory via --file' '
537 cd x &&
538 git config --file=../other-config --get ein.bahn >actual &&
539 test_cmp expect actual
543 cat > expect << EOF
544 [ein]
545 bahn = strasse
546 [anwohner]
547 park = ausweis
550 test_expect_success '--set in alternative file' '
551 git config --file=other-config anwohner.park ausweis &&
552 test_cmp expect other-config
555 cat > .git/config << EOF
556 # Hallo
557 #Bello
558 [branch "eins"]
559 x = 1
560 [branch.eins]
561 y = 1
562 [branch "1 234 blabl/a"]
563 weird
566 test_expect_success 'rename section' '
567 git config --rename-section branch.eins branch.zwei
570 cat > expect << EOF
571 # Hallo
572 #Bello
573 [branch "zwei"]
574 x = 1
575 [branch "zwei"]
576 y = 1
577 [branch "1 234 blabl/a"]
578 weird
581 test_expect_success 'rename succeeded' '
582 test_cmp expect .git/config
585 test_expect_success 'rename non-existing section' '
586 test_must_fail git config --rename-section \
587 branch."world domination" branch.drei
590 test_expect_success 'rename succeeded' '
591 test_cmp expect .git/config
594 test_expect_success 'rename another section' '
595 git config --rename-section branch."1 234 blabl/a" branch.drei
598 cat > expect << EOF
599 # Hallo
600 #Bello
601 [branch "zwei"]
602 x = 1
603 [branch "zwei"]
604 y = 1
605 [branch "drei"]
606 weird
609 test_expect_success 'rename succeeded' '
610 test_cmp expect .git/config
613 cat >> .git/config << EOF
614 [branch "vier"] z = 1
617 test_expect_success 'rename a section with a var on the same line' '
618 git config --rename-section branch.vier branch.zwei
621 cat > expect << EOF
622 # Hallo
623 #Bello
624 [branch "zwei"]
625 x = 1
626 [branch "zwei"]
627 y = 1
628 [branch "drei"]
629 weird
630 [branch "zwei"]
631 z = 1
634 test_expect_success 'rename succeeded' '
635 test_cmp expect .git/config
638 test_expect_success 'renaming empty section name is rejected' '
639 test_must_fail git config --rename-section branch.zwei ""
642 test_expect_success 'renaming to bogus section is rejected' '
643 test_must_fail git config --rename-section branch.zwei "bogus name"
646 cat >> .git/config << EOF
647 [branch "zwei"] a = 1 [branch "vier"]
650 test_expect_success 'remove section' '
651 git config --remove-section branch.zwei
654 cat > expect << EOF
655 # Hallo
656 #Bello
657 [branch "drei"]
658 weird
661 test_expect_success 'section was removed properly' '
662 test_cmp expect .git/config
665 cat > expect << EOF
666 [gitcvs]
667 enabled = true
668 dbname = %Ggitcvs2.%a.%m.sqlite
669 [gitcvs "ext"]
670 dbname = %Ggitcvs1.%a.%m.sqlite
673 test_expect_success 'section ending' '
674 rm -f .git/config &&
675 git config gitcvs.enabled true &&
676 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
677 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
678 test_cmp expect .git/config
682 test_expect_success numbers '
683 git config kilo.gram 1k &&
684 git config mega.ton 1m &&
685 echo 1024 >expect &&
686 echo 1048576 >>expect &&
687 git config --int --get kilo.gram >actual &&
688 git config --int --get mega.ton >>actual &&
689 test_cmp expect actual
692 test_expect_success '--int is at least 64 bits' '
693 git config giga.watts 121g &&
694 echo 129922760704 >expect &&
695 git config --int --get giga.watts >actual &&
696 test_cmp expect actual
699 test_expect_success 'invalid unit' '
700 git config aninvalid.unit "1auto" &&
701 echo 1auto >expect &&
702 git config aninvalid.unit >actual &&
703 test_cmp expect actual &&
704 test_must_fail git config --int --get aninvalid.unit 2>actual &&
705 test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
708 test_expect_success 'line number is reported correctly' '
709 printf "[bool]\n\tvar\n" >invalid &&
710 test_must_fail git config -f invalid --path bool.var 2>actual &&
711 test_i18ngrep "line 2" actual
714 test_expect_success 'invalid stdin config' '
715 echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
716 test_i18ngrep "bad config line 1 in standard input" output
719 cat > expect << EOF
720 true
721 false
722 true
723 false
724 true
725 false
726 true
727 false
730 test_expect_success bool '
732 git config bool.true1 01 &&
733 git config bool.true2 -1 &&
734 git config bool.true3 YeS &&
735 git config bool.true4 true &&
736 git config bool.false1 000 &&
737 git config bool.false2 "" &&
738 git config bool.false3 nO &&
739 git config bool.false4 FALSE &&
740 rm -f result &&
741 for i in 1 2 3 4
743 git config --bool --get bool.true$i >>result
744 git config --bool --get bool.false$i >>result
745 done &&
746 test_cmp expect result'
748 test_expect_success 'invalid bool (--get)' '
750 git config bool.nobool foobar &&
751 test_must_fail git config --bool --get bool.nobool'
753 test_expect_success 'invalid bool (set)' '
755 test_must_fail git config --bool bool.nobool foobar'
757 cat > expect <<\EOF
758 [bool]
759 true1 = true
760 true2 = true
761 true3 = true
762 true4 = true
763 false1 = false
764 false2 = false
765 false3 = false
766 false4 = false
769 test_expect_success 'set --bool' '
771 rm -f .git/config &&
772 git config --bool bool.true1 01 &&
773 git config --bool bool.true2 -1 &&
774 git config --bool bool.true3 YeS &&
775 git config --bool bool.true4 true &&
776 git config --bool bool.false1 000 &&
777 git config --bool bool.false2 "" &&
778 git config --bool bool.false3 nO &&
779 git config --bool bool.false4 FALSE &&
780 test_cmp expect .git/config'
782 cat > expect <<\EOF
783 [int]
784 val1 = 1
785 val2 = -1
786 val3 = 5242880
789 test_expect_success 'set --int' '
791 rm -f .git/config &&
792 git config --int int.val1 01 &&
793 git config --int int.val2 -1 &&
794 git config --int int.val3 5m &&
795 test_cmp expect .git/config
798 test_expect_success 'get --bool-or-int' '
799 cat >.git/config <<-\EOF &&
800 [bool]
801 true1
802 true2 = true
803 false = false
804 [int]
805 int1 = 0
806 int2 = 1
807 int3 = -1
809 cat >expect <<-\EOF &&
810 true
811 true
812 false
818 git config --bool-or-int bool.true1 &&
819 git config --bool-or-int bool.true2 &&
820 git config --bool-or-int bool.false &&
821 git config --bool-or-int int.int1 &&
822 git config --bool-or-int int.int2 &&
823 git config --bool-or-int int.int3
824 } >actual &&
825 test_cmp expect actual
828 cat >expect <<\EOF
829 [bool]
830 true1 = true
831 false1 = false
832 true2 = true
833 false2 = false
834 [int]
835 int1 = 0
836 int2 = 1
837 int3 = -1
840 test_expect_success 'set --bool-or-int' '
841 rm -f .git/config &&
842 git config --bool-or-int bool.true1 true &&
843 git config --bool-or-int bool.false1 false &&
844 git config --bool-or-int bool.true2 yes &&
845 git config --bool-or-int bool.false2 no &&
846 git config --bool-or-int int.int1 0 &&
847 git config --bool-or-int int.int2 1 &&
848 git config --bool-or-int int.int3 -1 &&
849 test_cmp expect .git/config
852 cat >expect <<\EOF
853 [path]
854 home = ~/
855 normal = /dev/null
856 trailingtilde = foo~
859 test_expect_success !MINGW 'set --path' '
860 rm -f .git/config &&
861 git config --path path.home "~/" &&
862 git config --path path.normal "/dev/null" &&
863 git config --path path.trailingtilde "foo~" &&
864 test_cmp expect .git/config'
866 if test_have_prereq !MINGW && test "${HOME+set}"
867 then
868 test_set_prereq HOMEVAR
871 cat >expect <<EOF
872 $HOME/
873 /dev/null
874 foo~
877 test_expect_success HOMEVAR 'get --path' '
878 git config --get --path path.home > result &&
879 git config --get --path path.normal >> result &&
880 git config --get --path path.trailingtilde >> result &&
881 test_cmp expect result
884 cat >expect <<\EOF
885 /dev/null
886 foo~
889 test_expect_success !MINGW 'get --path copes with unset $HOME' '
891 unset HOME;
892 test_must_fail git config --get --path path.home \
893 >result 2>msg &&
894 git config --get --path path.normal >>result &&
895 git config --get --path path.trailingtilde >>result
896 ) &&
897 test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
898 test_cmp expect result
901 test_expect_success 'get --path barfs on boolean variable' '
902 echo "[path]bool" >.git/config &&
903 test_must_fail git config --get --path path.bool
906 test_expect_success 'get --expiry-date' '
907 rel="3.weeks.5.days.00:00" &&
908 rel_out="$rel ->" &&
909 cat >.git/config <<-\EOF &&
910 [date]
911 valid1 = "3.weeks.5.days 00:00"
912 valid2 = "Fri Jun 4 15:46:55 2010"
913 valid3 = "2017/11/11 11:11:11PM"
914 valid4 = "2017/11/10 09:08:07 PM"
915 valid5 = "never"
916 invalid1 = "abc"
918 cat >expect <<-EOF &&
919 $(test-date timestamp $rel)
920 1275666415
921 1510441871
922 1510348087
926 echo "$rel_out $(git config --expiry-date date.valid1)"
927 git config --expiry-date date.valid2 &&
928 git config --expiry-date date.valid3 &&
929 git config --expiry-date date.valid4 &&
930 git config --expiry-date date.valid5
931 } >actual &&
932 test_cmp expect actual &&
933 test_must_fail git config --expiry-date date.invalid1
936 cat > expect << EOF
937 [quote]
938 leading = " test"
939 ending = "test "
940 semicolon = "test;test"
941 hash = "test#test"
943 test_expect_success 'quoting' '
944 rm -f .git/config &&
945 git config quote.leading " test" &&
946 git config quote.ending "test " &&
947 git config quote.semicolon "test;test" &&
948 git config quote.hash "test#test" &&
949 test_cmp expect .git/config
952 test_expect_success 'key with newline' '
953 test_must_fail git config "key.with
954 newline" 123'
956 test_expect_success 'value with newline' 'git config key.sub value.with\\\
957 newline'
959 cat > .git/config <<\EOF
960 [section]
961 ; comment \
962 continued = cont\
963 inued
964 noncont = not continued ; \
965 quotecont = "cont;\
966 inued"
969 cat > expect <<\EOF
970 section.continued=continued
971 section.noncont=not continued
972 section.quotecont=cont;inued
975 test_expect_success 'value continued on next line' '
976 git config --list > result &&
977 test_cmp result expect
980 cat > .git/config <<\EOF
981 [section "sub=section"]
982 val1 = foo=bar
983 val2 = foo\nbar
984 val3 = \n\n
985 val4 =
986 val5
989 cat > expect <<\EOF
990 section.sub=section.val1
991 foo=barQsection.sub=section.val2
993 barQsection.sub=section.val3
996 Qsection.sub=section.val4
997 Qsection.sub=section.val5Q
999 test_expect_success '--null --list' '
1000 git config --null --list >result.raw &&
1001 nul_to_q <result.raw >result &&
1002 echo >>result &&
1003 test_cmp expect result
1006 test_expect_success '--null --get-regexp' '
1007 git config --null --get-regexp "val[0-9]" >result.raw &&
1008 nul_to_q <result.raw >result &&
1009 echo >>result &&
1010 test_cmp expect result
1013 test_expect_success 'inner whitespace kept verbatim' '
1014 git config section.val "foo bar" &&
1015 echo "foo bar" >expect &&
1016 git config section.val >actual &&
1017 test_cmp expect actual
1020 test_expect_success SYMLINKS 'symlinked configuration' '
1021 ln -s notyet myconfig &&
1022 git config --file=myconfig test.frotz nitfol &&
1023 test -h myconfig &&
1024 test -f notyet &&
1025 test "z$(git config --file=notyet test.frotz)" = znitfol &&
1026 git config --file=myconfig test.xyzzy rezrov &&
1027 test -h myconfig &&
1028 test -f notyet &&
1029 cat >expect <<-\EOF &&
1030 nitfol
1031 rezrov
1034 git config --file=notyet test.frotz &&
1035 git config --file=notyet test.xyzzy
1036 } >actual &&
1037 test_cmp expect actual
1040 test_expect_success 'nonexistent configuration' '
1041 test_must_fail git config --file=doesnotexist --list &&
1042 test_must_fail git config --file=doesnotexist test.xyzzy
1045 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
1046 ln -s doesnotexist linktonada &&
1047 ln -s linktonada linktolinktonada &&
1048 test_must_fail git config --file=linktonada --list &&
1049 test_must_fail git config --file=linktolinktonada --list
1052 test_expect_success 'check split_cmdline return' "
1053 git config alias.split-cmdline-fix 'echo \"' &&
1054 test_must_fail git split-cmdline-fix &&
1055 echo foo > foo &&
1056 git add foo &&
1057 git commit -m 'initial commit' &&
1058 git config branch.master.mergeoptions 'echo \"' &&
1059 test_must_fail git merge master
1062 test_expect_success 'git -c "key=value" support' '
1063 cat >expect <<-\EOF &&
1064 value
1065 value
1066 true
1069 git -c core.name=value config core.name &&
1070 git -c foo.CamelCase=value config foo.camelcase &&
1071 git -c foo.flag config --bool foo.flag
1072 } >actual &&
1073 test_cmp expect actual &&
1074 test_must_fail git -c name=value config core.name
1077 # We just need a type-specifier here that cares about the
1078 # distinction internally between a NULL boolean and a real
1079 # string (because most of git's internal parsers do care).
1080 # Using "--path" works, but we do not otherwise care about
1081 # its semantics.
1082 test_expect_success 'git -c can represent empty string' '
1083 echo >expect &&
1084 git -c foo.empty= config --path foo.empty >actual &&
1085 test_cmp expect actual
1088 test_expect_success 'key sanity-checking' '
1089 test_must_fail git config foo=bar &&
1090 test_must_fail git config foo=.bar &&
1091 test_must_fail git config foo.ba=r &&
1092 test_must_fail git config foo.1bar &&
1093 test_must_fail git config foo."ba
1094 z".bar &&
1095 test_must_fail git config . false &&
1096 test_must_fail git config .foo false &&
1097 test_must_fail git config foo. false &&
1098 test_must_fail git config .foo. false &&
1099 git config foo.bar true &&
1100 git config foo."ba =z".bar false
1103 test_expect_success 'git -c works with aliases of builtins' '
1104 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
1105 echo bar >expect &&
1106 git checkconfig >actual &&
1107 test_cmp expect actual
1110 test_expect_success 'aliases can be CamelCased' '
1111 test_config alias.CamelCased "rev-parse HEAD" &&
1112 git CamelCased >out &&
1113 git rev-parse HEAD >expect &&
1114 test_cmp expect out
1117 test_expect_success 'git -c does not split values on equals' '
1118 echo "value with = in it" >expect &&
1119 git -c core.foo="value with = in it" config core.foo >actual &&
1120 test_cmp expect actual
1123 test_expect_success 'git -c dies on bogus config' '
1124 test_must_fail git -c core.bare=foo rev-parse
1127 test_expect_success 'git -c complains about empty key' '
1128 test_must_fail git -c "=foo" rev-parse
1131 test_expect_success 'git -c complains about empty key and value' '
1132 test_must_fail git -c "" rev-parse
1135 test_expect_success 'multiple git -c appends config' '
1136 test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
1137 cat >expect <<-\EOF &&
1138 x.one 1
1139 x.two 2
1141 git -c x.one=1 x >actual &&
1142 test_cmp expect actual
1145 test_expect_success 'last one wins: two level vars' '
1147 # sec.var and sec.VAR are the same variable, as the first
1148 # and the last level of a configuration variable name is
1149 # case insensitive.
1151 echo VAL >expect &&
1153 git -c sec.var=val -c sec.VAR=VAL config --get sec.var >actual &&
1154 test_cmp expect actual &&
1155 git -c SEC.var=val -c sec.var=VAL config --get sec.var >actual &&
1156 test_cmp expect actual &&
1158 git -c sec.var=val -c sec.VAR=VAL config --get SEC.var >actual &&
1159 test_cmp expect actual &&
1160 git -c SEC.var=val -c sec.var=VAL config --get sec.VAR >actual &&
1161 test_cmp expect actual
1164 test_expect_success 'last one wins: three level vars' '
1166 # v.a.r and v.A.r are not the same variable, as the middle
1167 # level of a three-level configuration variable name is
1168 # case sensitive.
1170 echo val >expect &&
1171 git -c v.a.r=val -c v.A.r=VAL config --get v.a.r >actual &&
1172 test_cmp expect actual &&
1173 git -c v.a.r=val -c v.A.r=VAL config --get V.a.R >actual &&
1174 test_cmp expect actual &&
1176 # v.a.r and V.a.R are the same variable, as the first
1177 # and the last level of a configuration variable name is
1178 # case insensitive.
1180 echo VAL >expect &&
1181 git -c v.a.r=val -c v.a.R=VAL config --get v.a.r >actual &&
1182 test_cmp expect actual &&
1183 git -c v.a.r=val -c V.a.r=VAL config --get v.a.r >actual &&
1184 test_cmp expect actual &&
1185 git -c v.a.r=val -c v.a.R=VAL config --get V.a.R >actual &&
1186 test_cmp expect actual &&
1187 git -c v.a.r=val -c V.a.r=VAL config --get V.a.R >actual &&
1188 test_cmp expect actual
1191 test_expect_success 'old-fashioned settings are case insensitive' '
1192 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1194 cat >testConfig_actual <<-EOF &&
1195 [V.A]
1196 r = value1
1198 q_to_tab >testConfig_expect <<-EOF &&
1199 [V.A]
1200 Qr = value2
1202 git config -f testConfig_actual "v.a.r" value2 &&
1203 test_cmp testConfig_expect testConfig_actual &&
1205 cat >testConfig_actual <<-EOF &&
1206 [V.A]
1207 r = value1
1209 q_to_tab >testConfig_expect <<-EOF &&
1210 [V.A]
1211 QR = value2
1213 git config -f testConfig_actual "V.a.R" value2 &&
1214 test_cmp testConfig_expect testConfig_actual &&
1216 cat >testConfig_actual <<-EOF &&
1217 [V.A]
1218 r = value1
1220 q_to_tab >testConfig_expect <<-EOF &&
1221 [V.A]
1222 r = value1
1223 Qr = value2
1225 git config -f testConfig_actual "V.A.r" value2 &&
1226 test_cmp testConfig_expect testConfig_actual &&
1228 cat >testConfig_actual <<-EOF &&
1229 [V.A]
1230 r = value1
1232 q_to_tab >testConfig_expect <<-EOF &&
1233 [V.A]
1234 r = value1
1235 Qr = value2
1237 git config -f testConfig_actual "v.A.r" value2 &&
1238 test_cmp testConfig_expect testConfig_actual
1241 test_expect_success 'setting different case sensitive subsections ' '
1242 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1244 cat >testConfig_actual <<-EOF &&
1245 [V "A"]
1246 R = v1
1247 [K "E"]
1248 Y = v1
1249 [a "b"]
1250 c = v1
1251 [d "e"]
1252 f = v1
1254 q_to_tab >testConfig_expect <<-EOF &&
1255 [V "A"]
1256 Qr = v2
1257 [K "E"]
1258 Qy = v2
1259 [a "b"]
1260 Qc = v2
1261 [d "e"]
1262 f = v1
1263 [d "E"]
1264 Qf = v2
1266 # exact match
1267 git config -f testConfig_actual a.b.c v2 &&
1268 # match section and subsection, key is cased differently.
1269 git config -f testConfig_actual K.E.y v2 &&
1270 # section and key are matched case insensitive, but subsection needs
1271 # to match; When writing out new values only the key is adjusted
1272 git config -f testConfig_actual v.A.r v2 &&
1273 # subsection is not matched:
1274 git config -f testConfig_actual d.E.f v2 &&
1275 test_cmp testConfig_expect testConfig_actual
1278 for VAR in a .a a. a.0b a."b c". a."b c".0d
1280 test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" '
1281 test_must_fail git -c "$VAR=VAL" config -l
1283 done
1285 for VAR in a.b a."b c".d
1287 test_expect_success "git -c $VAR=VAL works with valid '$VAR'" '
1288 echo VAL >expect &&
1289 git -c "$VAR=VAL" config --get "$VAR" >actual &&
1290 test_cmp expect actual
1292 done
1294 test_expect_success 'git -c is not confused by empty environment' '
1295 GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
1298 test_expect_success 'git config --edit works' '
1299 git config -f tmp test.value no &&
1300 echo test.value=yes >expect &&
1301 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1302 git config -f tmp --list >actual &&
1303 test_cmp expect actual
1306 test_expect_success 'git config --edit respects core.editor' '
1307 git config -f tmp test.value no &&
1308 echo test.value=yes >expect &&
1309 test_config core.editor "echo [test]value=yes >" &&
1310 git config -f tmp --edit &&
1311 git config -f tmp --list >actual &&
1312 test_cmp expect actual
1315 # malformed configuration files
1316 test_expect_success 'barf on syntax error' '
1317 cat >.git/config <<-\EOF &&
1318 # broken section line
1319 [section]
1320 key garbage
1322 test_must_fail git config --get section.key >actual 2>error &&
1323 test_i18ngrep " line 3 " error
1326 test_expect_success 'barf on incomplete section header' '
1327 cat >.git/config <<-\EOF &&
1328 # broken section line
1329 [section
1330 key = value
1332 test_must_fail git config --get section.key >actual 2>error &&
1333 test_i18ngrep " line 2 " error
1336 test_expect_success 'barf on incomplete string' '
1337 cat >.git/config <<-\EOF &&
1338 # broken section line
1339 [section]
1340 key = "value string
1342 test_must_fail git config --get section.key >actual 2>error &&
1343 test_i18ngrep " line 3 " error
1346 test_expect_success 'urlmatch' '
1347 cat >.git/config <<-\EOF &&
1348 [http]
1349 sslVerify
1350 [http "https://weak.example.com"]
1351 sslVerify = false
1352 cookieFile = /tmp/cookie.txt
1355 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1356 test_must_be_empty actual &&
1358 echo true >expect &&
1359 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
1360 test_cmp expect actual &&
1362 echo false >expect &&
1363 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual &&
1364 test_cmp expect actual &&
1367 echo http.cookiefile /tmp/cookie.txt &&
1368 echo http.sslverify false
1369 } >expect &&
1370 git config --get-urlmatch HTTP https://weak.example.com >actual &&
1371 test_cmp expect actual
1374 test_expect_success 'urlmatch favors more specific URLs' '
1375 cat >.git/config <<-\EOF &&
1376 [http "https://example.com/"]
1377 cookieFile = /tmp/root.txt
1378 [http "https://example.com/subdirectory"]
1379 cookieFile = /tmp/subdirectory.txt
1380 [http "https://user@example.com/"]
1381 cookieFile = /tmp/user.txt
1382 [http "https://averylonguser@example.com/"]
1383 cookieFile = /tmp/averylonguser.txt
1384 [http "https://preceding.example.com"]
1385 cookieFile = /tmp/preceding.txt
1386 [http "https://*.example.com"]
1387 cookieFile = /tmp/wildcard.txt
1388 [http "https://*.example.com/wildcardwithsubdomain"]
1389 cookieFile = /tmp/wildcardwithsubdomain.txt
1390 [http "https://trailing.example.com"]
1391 cookieFile = /tmp/trailing.txt
1392 [http "https://user@*.example.com/"]
1393 cookieFile = /tmp/wildcardwithuser.txt
1394 [http "https://sub.example.com/"]
1395 cookieFile = /tmp/sub.txt
1398 echo http.cookiefile /tmp/root.txt >expect &&
1399 git config --get-urlmatch HTTP https://example.com >actual &&
1400 test_cmp expect actual &&
1402 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1403 git config --get-urlmatch HTTP https://example.com/subdirectory >actual &&
1404 test_cmp expect actual &&
1406 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1407 git config --get-urlmatch HTTP https://example.com/subdirectory/nested >actual &&
1408 test_cmp expect actual &&
1410 echo http.cookiefile /tmp/user.txt >expect &&
1411 git config --get-urlmatch HTTP https://user@example.com/ >actual &&
1412 test_cmp expect actual &&
1414 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1415 git config --get-urlmatch HTTP https://averylonguser@example.com/subdirectory >actual &&
1416 test_cmp expect actual &&
1418 echo http.cookiefile /tmp/preceding.txt >expect &&
1419 git config --get-urlmatch HTTP https://preceding.example.com >actual &&
1420 test_cmp expect actual &&
1422 echo http.cookiefile /tmp/wildcard.txt >expect &&
1423 git config --get-urlmatch HTTP https://wildcard.example.com >actual &&
1424 test_cmp expect actual &&
1426 echo http.cookiefile /tmp/sub.txt >expect &&
1427 git config --get-urlmatch HTTP https://sub.example.com/wildcardwithsubdomain >actual &&
1428 test_cmp expect actual &&
1430 echo http.cookiefile /tmp/trailing.txt >expect &&
1431 git config --get-urlmatch HTTP https://trailing.example.com >actual &&
1432 test_cmp expect actual &&
1434 echo http.cookiefile /tmp/sub.txt >expect &&
1435 git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
1436 test_cmp expect actual
1439 test_expect_success 'urlmatch with wildcard' '
1440 cat >.git/config <<-\EOF &&
1441 [http]
1442 sslVerify
1443 [http "https://*.example.com"]
1444 sslVerify = false
1445 cookieFile = /tmp/cookie.txt
1448 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1449 test_must_be_empty actual &&
1451 echo true >expect &&
1452 git config --bool --get-urlmatch http.SSLverify https://example.com >actual &&
1453 test_cmp expect actual &&
1455 echo true >expect &&
1456 git config --bool --get-urlmatch http.SSLverify https://good-example.com >actual &&
1457 test_cmp expect actual &&
1459 echo true >expect &&
1460 git config --bool --get-urlmatch http.sslverify https://deep.nested.example.com >actual &&
1461 test_cmp expect actual &&
1463 echo false >expect &&
1464 git config --bool --get-urlmatch http.sslverify https://good.example.com >actual &&
1465 test_cmp expect actual &&
1468 echo http.cookiefile /tmp/cookie.txt &&
1469 echo http.sslverify false
1470 } >expect &&
1471 git config --get-urlmatch HTTP https://good.example.com >actual &&
1472 test_cmp expect actual &&
1474 echo http.sslverify >expect &&
1475 git config --get-urlmatch HTTP https://more.example.com.au >actual &&
1476 test_cmp expect actual
1479 # good section hygiene
1480 test_expect_success '--unset last key removes section (except if commented)' '
1481 cat >.git/config <<-\EOF &&
1482 # some generic comment on the configuration file itself
1483 # a comment specific to this "section" section.
1484 [section]
1485 # some intervening lines
1486 # that should also be dropped
1488 key = value
1489 # please be careful when you update the above variable
1492 cat >expect <<-\EOF &&
1493 # some generic comment on the configuration file itself
1494 # a comment specific to this "section" section.
1495 [section]
1496 # some intervening lines
1497 # that should also be dropped
1499 # please be careful when you update the above variable
1502 git config --unset section.key &&
1503 test_cmp expect .git/config &&
1505 cat >.git/config <<-\EOF &&
1506 [section]
1507 key = value
1508 [next-section]
1511 cat >expect <<-\EOF &&
1512 [next-section]
1515 git config --unset section.key &&
1516 test_cmp expect .git/config &&
1518 q_to_tab >.git/config <<-\EOF &&
1519 [one]
1520 Qkey = "multiline \
1521 QQ# with comment"
1522 [two]
1523 key = true
1525 git config --unset two.key &&
1526 ! grep two .git/config &&
1528 q_to_tab >.git/config <<-\EOF &&
1529 [one]
1530 Qkey = "multiline \
1531 QQ# with comment"
1532 [one]
1533 key = true
1535 git config --unset-all one.key &&
1536 test_line_count = 0 .git/config &&
1538 q_to_tab >.git/config <<-\EOF &&
1539 [one]
1540 Qkey = true
1541 Q# a comment not at the start
1542 [two]
1543 Qkey = true
1545 git config --unset two.key &&
1546 grep two .git/config &&
1548 q_to_tab >.git/config <<-\EOF &&
1549 [one]
1550 Qkey = not [two "subsection"]
1551 [two "subsection"]
1552 [two "subsection"]
1553 Qkey = true
1554 [TWO "subsection"]
1555 [one]
1557 git config --unset two.subsection.key &&
1558 test "not [two subsection]" = "$(git config one.key)" &&
1559 test_line_count = 3 .git/config
1562 test_expect_success '--unset-all removes section if empty & uncommented' '
1563 cat >.git/config <<-\EOF &&
1564 [section]
1565 key = value1
1566 key = value2
1569 git config --unset-all section.key &&
1570 test_line_count = 0 .git/config
1573 test_expect_success 'adding a key into an empty section reuses header' '
1574 cat >.git/config <<-\EOF &&
1575 [section]
1578 q_to_tab >expect <<-\EOF &&
1579 [section]
1580 Qkey = value
1583 git config section.key value &&
1584 test_cmp expect .git/config
1587 test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
1588 chmod 0600 .git/config &&
1589 git config imap.pass Hunter2 &&
1590 perl -e \
1591 "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
1592 git config --rename-section imap pop &&
1593 perl -e \
1594 "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
1597 ! test_have_prereq MINGW ||
1598 HOME="$(pwd)" # convert to Windows path
1600 test_expect_success 'set up --show-origin tests' '
1601 INCLUDE_DIR="$HOME/include" &&
1602 mkdir -p "$INCLUDE_DIR" &&
1603 cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
1604 [user]
1605 absolute = include
1607 cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
1608 [user]
1609 relative = include
1611 cat >"$HOME"/.gitconfig <<-EOF &&
1612 [user]
1613 global = true
1614 override = global
1615 [include]
1616 path = "$INCLUDE_DIR/absolute.include"
1618 cat >.git/config <<-\EOF
1619 [user]
1620 local = true
1621 override = local
1622 [include]
1623 path = ../include/relative.include
1627 test_expect_success '--show-origin with --list' '
1628 cat >expect <<-EOF &&
1629 file:$HOME/.gitconfig user.global=true
1630 file:$HOME/.gitconfig user.override=global
1631 file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
1632 file:$INCLUDE_DIR/absolute.include user.absolute=include
1633 file:.git/config user.local=true
1634 file:.git/config user.override=local
1635 file:.git/config include.path=../include/relative.include
1636 file:.git/../include/relative.include user.relative=include
1637 command line: user.cmdline=true
1639 git -c user.cmdline=true config --list --show-origin >output &&
1640 test_cmp expect output
1643 test_expect_success '--show-origin with --list --null' '
1644 cat >expect <<-EOF &&
1645 file:$HOME/.gitconfigQuser.global
1646 trueQfile:$HOME/.gitconfigQuser.override
1647 globalQfile:$HOME/.gitconfigQinclude.path
1648 $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
1649 includeQfile:.git/configQuser.local
1650 trueQfile:.git/configQuser.override
1651 localQfile:.git/configQinclude.path
1652 ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
1653 includeQcommand line:Quser.cmdline
1654 trueQ
1656 git -c user.cmdline=true config --null --list --show-origin >output.raw &&
1657 nul_to_q <output.raw >output &&
1658 # The here-doc above adds a newline that the --null output would not
1659 # include. Add it here to make the two comparable.
1660 echo >>output &&
1661 test_cmp expect output
1664 test_expect_success '--show-origin with single file' '
1665 cat >expect <<-\EOF &&
1666 file:.git/config user.local=true
1667 file:.git/config user.override=local
1668 file:.git/config include.path=../include/relative.include
1670 git config --local --list --show-origin >output &&
1671 test_cmp expect output
1674 test_expect_success '--show-origin with --get-regexp' '
1675 cat >expect <<-EOF &&
1676 file:$HOME/.gitconfig user.global true
1677 file:.git/config user.local true
1679 git config --show-origin --get-regexp "user\.[g|l].*" >output &&
1680 test_cmp expect output
1683 test_expect_success '--show-origin getting a single key' '
1684 cat >expect <<-\EOF &&
1685 file:.git/config local
1687 git config --show-origin user.override >output &&
1688 test_cmp expect output
1691 test_expect_success 'set up custom config file' '
1692 CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
1693 cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
1694 [user]
1695 custom = true
1699 test_expect_success !MINGW '--show-origin escape special file name characters' '
1700 cat >expect <<-\EOF &&
1701 file:"file\" (dq) and spaces.conf" user.custom=true
1703 git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1704 test_cmp expect output
1707 test_expect_success '--show-origin stdin' '
1708 cat >expect <<-\EOF &&
1709 standard input: user.custom=true
1711 git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
1712 test_cmp expect output
1715 test_expect_success '--show-origin stdin with file include' '
1716 cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
1717 [user]
1718 stdin = include
1720 cat >expect <<-EOF &&
1721 file:$INCLUDE_DIR/stdin.include include
1723 echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
1724 | git config --show-origin --includes --file - user.stdin >output &&
1725 test_cmp expect output
1728 test_expect_success !MINGW '--show-origin blob' '
1729 cat >expect <<-\EOF &&
1730 blob:a9d9f9e555b5c6f07cbe09d3f06fe3df11e09c08 user.custom=true
1732 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
1733 git config --blob=$blob --show-origin --list >output &&
1734 test_cmp expect output
1737 test_expect_success !MINGW '--show-origin blob ref' '
1738 cat >expect <<-\EOF &&
1739 blob:"master:file\" (dq) and spaces.conf" user.custom=true
1741 git add "$CUSTOM_CONFIG_FILE" &&
1742 git commit -m "new config file" &&
1743 git config --blob=master:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1744 test_cmp expect output
1747 test_expect_success '--local requires a repo' '
1748 # we expect 128 to ensure that we do not simply
1749 # fail to find anything and return code "1"
1750 test_expect_code 128 nongit git config --local foo.bar
1753 test_expect_success '--replace-all does not invent newlines' '
1754 q_to_tab >.git/config <<-\EOF &&
1755 [abc]key
1756 QkeepSection
1757 [xyz]
1758 Qkey = 1
1759 [abc]
1760 Qkey = a
1762 q_to_tab >expect <<-\EOF &&
1763 [abc]
1764 QkeepSection
1765 [xyz]
1766 Qkey = 1
1767 [abc]
1768 Qkey = b
1770 git config --replace-all abc.key b &&
1771 test_cmp .git/config expect
1774 test_done