Sync with 2.34.8
[git.git] / t / t1300-config.sh
blob9df05ac2300e4cf4fec039db4dc535d4a3add401
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test git config in different settings'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
14 test_expect_success 'clear default config' '
15 rm -f .git/config
18 cat > expect << EOF
19 [section]
20 penguin = little blue
21 EOF
22 test_expect_success 'initial' '
23 git config section.penguin "little blue" &&
24 test_cmp expect .git/config
27 cat > expect << EOF
28 [section]
29 penguin = little blue
30 Movie = BadPhysics
31 EOF
32 test_expect_success 'mixed case' '
33 git config Section.Movie BadPhysics &&
34 test_cmp expect .git/config
37 cat > expect << EOF
38 [section]
39 penguin = little blue
40 Movie = BadPhysics
41 [Sections]
42 WhatEver = Second
43 EOF
44 test_expect_success 'similar section' '
45 git config Sections.WhatEver Second &&
46 test_cmp expect .git/config
49 cat > expect << EOF
50 [section]
51 penguin = little blue
52 Movie = BadPhysics
53 UPPERCASE = true
54 [Sections]
55 WhatEver = Second
56 EOF
57 test_expect_success 'uppercase section' '
58 git config SECTION.UPPERCASE true &&
59 test_cmp expect .git/config
62 test_expect_success 'replace with non-match' '
63 git config section.penguin kingpin !blue
66 test_expect_success 'replace with non-match (actually matching)' '
67 git config section.penguin "very blue" !kingpin
70 cat > expect << EOF
71 [section]
72 penguin = very blue
73 Movie = BadPhysics
74 UPPERCASE = true
75 penguin = kingpin
76 [Sections]
77 WhatEver = Second
78 EOF
80 test_expect_success 'non-match result' 'test_cmp expect .git/config'
82 test_expect_success 'find mixed-case key by canonical name' '
83 test_cmp_config Second sections.whatever
86 test_expect_success 'find mixed-case key by non-canonical name' '
87 test_cmp_config Second SeCtIoNs.WhAtEvEr
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 test_cmp_config one section.subsection.key &&
98 test_cmp_config two section.SubSection.key
101 cat > .git/config <<\EOF
102 [alpha]
103 bar = foo
104 [beta]
105 baz = multiple \
106 lines
107 foo = bar
110 test_expect_success 'unset with cont. lines' '
111 git config --unset beta.baz
114 cat > expect <<\EOF
115 [alpha]
116 bar = foo
117 [beta]
118 foo = bar
121 test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config'
123 cat > .git/config << EOF
124 [beta] ; silly comment # another comment
125 noIndent= sillyValue ; 'nother silly comment
127 # empty line
128 ; comment
129 haha ="beta" # last silly comment
130 haha = hello
131 haha = bello
132 [nextSection] noNewline = ouch
135 cp .git/config .git/config2
137 test_expect_success 'multiple unset' '
138 git config --unset-all beta.haha
141 cat > expect << EOF
142 [beta] ; silly comment # another comment
143 noIndent= sillyValue ; 'nother silly comment
145 # empty line
146 ; comment
147 [nextSection] noNewline = ouch
150 test_expect_success 'multiple unset is correct' '
151 test_cmp expect .git/config
154 cp .git/config2 .git/config
156 test_expect_success '--replace-all missing value' '
157 test_must_fail git config --replace-all beta.haha &&
158 test_cmp .git/config2 .git/config
161 rm .git/config2
163 test_expect_success '--replace-all' '
164 git config --replace-all beta.haha gamma
167 cat > expect << EOF
168 [beta] ; silly comment # another comment
169 noIndent= sillyValue ; 'nother silly comment
171 # empty line
172 ; comment
173 haha = gamma
174 [nextSection] noNewline = ouch
177 test_expect_success 'all replaced' '
178 test_cmp expect .git/config
181 cat > expect << EOF
182 [beta] ; silly comment # another comment
183 noIndent= sillyValue ; 'nother silly comment
185 # empty line
186 ; comment
187 haha = alpha
188 [nextSection] noNewline = ouch
190 test_expect_success 'really mean test' '
191 git config beta.haha alpha &&
192 test_cmp expect .git/config
195 cat > expect << EOF
196 [beta] ; silly comment # another comment
197 noIndent= sillyValue ; 'nother silly comment
199 # empty line
200 ; comment
201 haha = alpha
202 [nextSection]
203 nonewline = wow
205 test_expect_success 'really really mean test' '
206 git config nextsection.nonewline wow &&
207 test_cmp expect .git/config
210 test_expect_success 'get value' '
211 test_cmp_config alpha beta.haha
214 cat > expect << EOF
215 [beta] ; silly comment # another comment
216 noIndent= sillyValue ; 'nother silly comment
218 # empty line
219 ; comment
220 [nextSection]
221 nonewline = wow
223 test_expect_success 'unset' '
224 git config --unset beta.haha &&
225 test_cmp expect .git/config
228 cat > expect << EOF
229 [beta] ; silly comment # another comment
230 noIndent= sillyValue ; 'nother silly comment
232 # empty line
233 ; comment
234 [nextSection]
235 nonewline = wow
236 NoNewLine = wow2 for me
238 test_expect_success 'multivar' '
239 git config nextsection.NoNewLine "wow2 for me" "for me$" &&
240 test_cmp expect .git/config
243 test_expect_success 'non-match' '
244 git config --get nextsection.nonewline !for
247 test_expect_success 'non-match value' '
248 test_cmp_config wow --get nextsection.nonewline !for
251 test_expect_success 'multi-valued get returns final one' '
252 test_cmp_config "wow2 for me" --get nextsection.nonewline
255 test_expect_success 'multi-valued get-all returns all' '
256 cat >expect <<-\EOF &&
258 wow2 for me
260 git config --get-all nextsection.nonewline >actual &&
261 test_cmp expect actual
264 cat > expect << EOF
265 [beta] ; silly comment # another comment
266 noIndent= sillyValue ; 'nother silly comment
268 # empty line
269 ; comment
270 [nextSection]
271 nonewline = wow3
272 NoNewLine = wow2 for me
274 test_expect_success 'multivar replace' '
275 git config nextsection.nonewline "wow3" "wow$" &&
276 test_cmp expect .git/config
279 test_expect_success 'ambiguous unset' '
280 test_must_fail git config --unset nextsection.nonewline
283 test_expect_success 'invalid unset' '
284 test_must_fail git config --unset somesection.nonewline
287 cat > expect << EOF
288 [beta] ; silly comment # another comment
289 noIndent= sillyValue ; 'nother silly comment
291 # empty line
292 ; comment
293 [nextSection]
294 NoNewLine = wow2 for me
297 test_expect_success 'multivar unset' '
298 git config --unset nextsection.nonewline "wow3$" &&
299 test_cmp expect .git/config
302 test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
304 test_expect_success 'correct key' 'git config 123456.a123 987'
306 test_expect_success 'hierarchical section' '
307 git config Version.1.2.3eX.Alpha beta
310 cat > expect << EOF
311 [beta] ; silly comment # another comment
312 noIndent= sillyValue ; 'nother silly comment
314 # empty line
315 ; comment
316 [nextSection]
317 NoNewLine = wow2 for me
318 [123456]
319 a123 = 987
320 [Version "1.2.3eX"]
321 Alpha = beta
324 test_expect_success 'hierarchical section value' '
325 test_cmp expect .git/config
328 cat > expect << EOF
329 beta.noindent=sillyValue
330 nextsection.nonewline=wow2 for me
331 123456.a123=987
332 version.1.2.3eX.alpha=beta
335 test_expect_success 'working --list' '
336 git config --list > output &&
337 test_cmp expect output
339 test_expect_success '--list without repo produces empty output' '
340 git --git-dir=nonexistent config --list >output &&
341 test_must_be_empty output
344 cat > expect << EOF
345 beta.noindent
346 nextsection.nonewline
347 123456.a123
348 version.1.2.3eX.alpha
351 test_expect_success '--name-only --list' '
352 git config --name-only --list >output &&
353 test_cmp expect output
356 cat > expect << EOF
357 beta.noindent sillyValue
358 nextsection.nonewline wow2 for me
361 test_expect_success '--get-regexp' '
362 git config --get-regexp in >output &&
363 test_cmp expect output
366 cat > expect << EOF
367 beta.noindent
368 nextsection.nonewline
371 test_expect_success '--name-only --get-regexp' '
372 git config --name-only --get-regexp in >output &&
373 test_cmp expect output
376 cat > expect << EOF
377 wow2 for me
378 wow4 for you
381 test_expect_success '--add' '
382 git config --add nextsection.nonewline "wow4 for you" &&
383 git config --get-all nextsection.nonewline > output &&
384 test_cmp expect output
387 cat > .git/config << EOF
388 [novalue]
389 variable
390 [emptyvalue]
391 variable =
394 test_expect_success 'get variable with no value' '
395 git config --get novalue.variable ^$
398 test_expect_success 'get variable with empty value' '
399 git config --get emptyvalue.variable ^$
402 echo novalue.variable > expect
404 test_expect_success 'get-regexp variable with no value' '
405 git config --get-regexp novalue > output &&
406 test_cmp expect output
409 echo 'novalue.variable true' > expect
411 test_expect_success 'get-regexp --bool variable with no value' '
412 git config --bool --get-regexp novalue > output &&
413 test_cmp expect output
416 echo 'emptyvalue.variable ' > expect
418 test_expect_success 'get-regexp variable with empty value' '
419 git config --get-regexp emptyvalue > output &&
420 test_cmp expect output
423 echo true > expect
425 test_expect_success 'get bool variable with no value' '
426 git config --bool novalue.variable > output &&
427 test_cmp expect output
430 echo false > expect
432 test_expect_success 'get bool variable with empty value' '
433 git config --bool emptyvalue.variable > output &&
434 test_cmp expect output
437 test_expect_success 'no arguments, but no crash' '
438 test_must_fail git config >output 2>&1 &&
439 test_i18ngrep usage output
442 cat > .git/config << EOF
443 [a.b]
444 c = d
447 cat > expect << EOF
448 [a.b]
449 c = d
451 x = y
454 test_expect_success 'new section is partial match of another' '
455 git config a.x y &&
456 test_cmp expect .git/config
459 cat > expect << EOF
460 [a.b]
461 c = d
463 x = y
464 b = c
466 x = y
469 test_expect_success 'new variable inserts into proper section' '
470 git config b.x y &&
471 git config a.b c &&
472 test_cmp expect .git/config
475 test_expect_success 'alternative --file (non-existing file should fail)' '
476 test_must_fail git config --file non-existing-config -l &&
477 test_must_fail git config --file non-existing-config test.xyzzy
480 cat > other-config << EOF
481 [ein]
482 bahn = strasse
485 cat > expect << EOF
486 ein.bahn=strasse
489 test_expect_success 'alternative GIT_CONFIG' '
490 GIT_CONFIG=other-config git config --list >output &&
491 test_cmp expect output
494 test_expect_success 'alternative GIT_CONFIG (--file)' '
495 git config --file other-config --list >output &&
496 test_cmp expect output
499 test_expect_success 'alternative GIT_CONFIG (--file=-)' '
500 git config --file - --list <other-config >output &&
501 test_cmp expect output
504 test_expect_success 'setting a value in stdin is an error' '
505 test_must_fail git config --file - some.value foo
508 test_expect_success 'editing stdin is an error' '
509 test_must_fail git config --file - --edit
512 test_expect_success 'refer config from subdirectory' '
513 mkdir x &&
514 test_cmp_config -C x strasse --file=../other-config --get ein.bahn
517 cat > expect << EOF
518 [ein]
519 bahn = strasse
520 [anwohner]
521 park = ausweis
524 test_expect_success '--set in alternative file' '
525 git config --file=other-config anwohner.park ausweis &&
526 test_cmp expect other-config
529 cat > .git/config << EOF
530 # Hallo
531 #Bello
532 [branch "eins"]
533 x = 1
534 [branch.eins]
535 y = 1
536 [branch "1 234 blabl/a"]
537 weird
540 test_expect_success 'rename section' '
541 git config --rename-section branch.eins branch.zwei
544 cat > expect << EOF
545 # Hallo
546 #Bello
547 [branch "zwei"]
548 x = 1
549 [branch "zwei"]
550 y = 1
551 [branch "1 234 blabl/a"]
552 weird
555 test_expect_success 'rename succeeded' '
556 test_cmp expect .git/config
559 test_expect_success 'rename non-existing section' '
560 test_must_fail git config --rename-section \
561 branch."world domination" branch.drei
564 test_expect_success 'rename succeeded' '
565 test_cmp expect .git/config
568 test_expect_success 'rename another section' '
569 git config --rename-section branch."1 234 blabl/a" branch.drei
572 cat > expect << EOF
573 # Hallo
574 #Bello
575 [branch "zwei"]
576 x = 1
577 [branch "zwei"]
578 y = 1
579 [branch "drei"]
580 weird
583 test_expect_success 'rename succeeded' '
584 test_cmp expect .git/config
587 cat >> .git/config << EOF
588 [branch "vier"] z = 1
591 test_expect_success 'rename a section with a var on the same line' '
592 git config --rename-section branch.vier branch.zwei
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
604 [branch "zwei"]
605 z = 1
608 test_expect_success 'rename succeeded' '
609 test_cmp expect .git/config
612 test_expect_success 'renaming empty section name is rejected' '
613 test_must_fail git config --rename-section branch.zwei ""
616 test_expect_success 'renaming to bogus section is rejected' '
617 test_must_fail git config --rename-section branch.zwei "bogus name"
620 test_expect_success 'renaming a section with a long line' '
622 printf "[b]\\n" &&
623 printf " c = d %1024s [a] e = f\\n" " " &&
624 printf "[a] g = h\\n"
625 } >y &&
626 git config -f y --rename-section a xyz &&
627 test_must_fail git config -f y b.e
630 test_expect_success 'renaming an embedded section with a long line' '
632 printf "[b]\\n" &&
633 printf " c = d %1024s [a] [foo] e = f\\n" " " &&
634 printf "[a] g = h\\n"
635 } >y &&
636 git config -f y --rename-section a xyz &&
637 test_must_fail git config -f y foo.e
640 test_expect_success 'renaming a section with an overly-long line' '
642 printf "[b]\\n" &&
643 printf " c = d %525000s e" " " &&
644 printf "[a] g = h\\n"
645 } >y &&
646 test_must_fail git config -f y --rename-section a xyz 2>err &&
647 grep "refusing to work with overly long line in .y. on line 2" err
650 cat >> .git/config << EOF
651 [branch "zwei"] a = 1 [branch "vier"]
654 test_expect_success 'remove section' '
655 git config --remove-section branch.zwei
658 cat > expect << EOF
659 # Hallo
660 #Bello
661 [branch "drei"]
662 weird
665 test_expect_success 'section was removed properly' '
666 test_cmp expect .git/config
669 cat > expect << EOF
670 [gitcvs]
671 enabled = true
672 dbname = %Ggitcvs2.%a.%m.sqlite
673 [gitcvs "ext"]
674 dbname = %Ggitcvs1.%a.%m.sqlite
677 test_expect_success 'section ending' '
678 rm -f .git/config &&
679 git config gitcvs.enabled true &&
680 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
681 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
682 test_cmp expect .git/config
686 test_expect_success numbers '
687 git config kilo.gram 1k &&
688 git config mega.ton 1m &&
689 echo 1024 >expect &&
690 echo 1048576 >>expect &&
691 git config --int --get kilo.gram >actual &&
692 git config --int --get mega.ton >>actual &&
693 test_cmp expect actual
696 test_expect_success '--int is at least 64 bits' '
697 git config giga.watts 121g &&
698 echo >expect &&
699 test_cmp_config 129922760704 --int --get giga.watts
702 test_expect_success 'invalid unit' '
703 git config aninvalid.unit "1auto" &&
704 test_cmp_config 1auto aninvalid.unit &&
705 test_must_fail git config --int --get aninvalid.unit 2>actual &&
706 test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
709 test_expect_success 'invalid unit boolean' '
710 git config commit.gpgsign "1true" &&
711 test_cmp_config 1true commit.gpgsign &&
712 test_must_fail git config --bool --get commit.gpgsign 2>actual &&
713 test_i18ngrep "bad boolean config value .1true. for .commit.gpgsign." actual
716 test_expect_success 'line number is reported correctly' '
717 printf "[bool]\n\tvar\n" >invalid &&
718 test_must_fail git config -f invalid --path bool.var 2>actual &&
719 test_i18ngrep "line 2" actual
722 test_expect_success 'invalid stdin config' '
723 echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
724 test_i18ngrep "bad config line 1 in standard input" output
727 cat > expect << EOF
728 true
729 false
730 true
731 false
732 true
733 false
734 true
735 false
738 test_expect_success bool '
740 git config bool.true1 01 &&
741 git config bool.true2 -1 &&
742 git config bool.true3 YeS &&
743 git config bool.true4 true &&
744 git config bool.false1 000 &&
745 git config bool.false2 "" &&
746 git config bool.false3 nO &&
747 git config bool.false4 FALSE &&
748 rm -f result &&
749 for i in 1 2 3 4
751 git config --bool --get bool.true$i >>result &&
752 git config --bool --get bool.false$i >>result || return 1
753 done &&
754 test_cmp expect result'
756 test_expect_success 'invalid bool (--get)' '
758 git config bool.nobool foobar &&
759 test_must_fail git config --bool --get bool.nobool'
761 test_expect_success 'invalid bool (set)' '
763 test_must_fail git config --bool bool.nobool foobar'
765 cat > expect <<\EOF
766 [bool]
767 true1 = true
768 true2 = true
769 true3 = true
770 true4 = true
771 false1 = false
772 false2 = false
773 false3 = false
774 false4 = false
777 test_expect_success 'set --bool' '
779 rm -f .git/config &&
780 git config --bool bool.true1 01 &&
781 git config --bool bool.true2 -1 &&
782 git config --bool bool.true3 YeS &&
783 git config --bool bool.true4 true &&
784 git config --bool bool.false1 000 &&
785 git config --bool bool.false2 "" &&
786 git config --bool bool.false3 nO &&
787 git config --bool bool.false4 FALSE &&
788 test_cmp expect .git/config'
790 cat > expect <<\EOF
791 [int]
792 val1 = 1
793 val2 = -1
794 val3 = 5242880
797 test_expect_success 'set --int' '
799 rm -f .git/config &&
800 git config --int int.val1 01 &&
801 git config --int int.val2 -1 &&
802 git config --int int.val3 5m &&
803 test_cmp expect .git/config
806 test_expect_success 'get --bool-or-int' '
807 cat >.git/config <<-\EOF &&
808 [bool]
809 true1
810 true2 = true
811 false = false
812 [int]
813 int1 = 0
814 int2 = 1
815 int3 = -1
817 cat >expect <<-\EOF &&
818 true
819 true
820 false
826 git config --bool-or-int bool.true1 &&
827 git config --bool-or-int bool.true2 &&
828 git config --bool-or-int bool.false &&
829 git config --bool-or-int int.int1 &&
830 git config --bool-or-int int.int2 &&
831 git config --bool-or-int int.int3
832 } >actual &&
833 test_cmp expect actual
836 cat >expect <<\EOF
837 [bool]
838 true1 = true
839 false1 = false
840 true2 = true
841 false2 = false
842 [int]
843 int1 = 0
844 int2 = 1
845 int3 = -1
848 test_expect_success 'set --bool-or-int' '
849 rm -f .git/config &&
850 git config --bool-or-int bool.true1 true &&
851 git config --bool-or-int bool.false1 false &&
852 git config --bool-or-int bool.true2 yes &&
853 git config --bool-or-int bool.false2 no &&
854 git config --bool-or-int int.int1 0 &&
855 git config --bool-or-int int.int2 1 &&
856 git config --bool-or-int int.int3 -1 &&
857 test_cmp expect .git/config
860 cat >expect <<\EOF
861 [path]
862 home = ~/
863 normal = /dev/null
864 trailingtilde = foo~
867 test_expect_success !MINGW 'set --path' '
868 rm -f .git/config &&
869 git config --path path.home "~/" &&
870 git config --path path.normal "/dev/null" &&
871 git config --path path.trailingtilde "foo~" &&
872 test_cmp expect .git/config'
874 if test_have_prereq !MINGW && test "${HOME+set}"
875 then
876 test_set_prereq HOMEVAR
879 cat >expect <<EOF
880 $HOME/
881 /dev/null
882 foo~
885 test_expect_success HOMEVAR 'get --path' '
886 git config --get --path path.home > result &&
887 git config --get --path path.normal >> result &&
888 git config --get --path path.trailingtilde >> result &&
889 test_cmp expect result
892 cat >expect <<\EOF
893 /dev/null
894 foo~
897 test_expect_success !MINGW 'get --path copes with unset $HOME' '
899 sane_unset HOME &&
900 test_must_fail git config --get --path path.home \
901 >result 2>msg &&
902 git config --get --path path.normal >>result &&
903 git config --get --path path.trailingtilde >>result
904 ) &&
905 test_i18ngrep "[Ff]ailed to expand.*~/" msg &&
906 test_cmp expect result
909 test_expect_success 'get --path barfs on boolean variable' '
910 echo "[path]bool" >.git/config &&
911 test_must_fail git config --get --path path.bool
914 test_expect_success 'get --expiry-date' '
915 rel="3.weeks.5.days.00:00" &&
916 rel_out="$rel ->" &&
917 cat >.git/config <<-\EOF &&
918 [date]
919 valid1 = "3.weeks.5.days 00:00"
920 valid2 = "Fri Jun 4 15:46:55 2010"
921 valid3 = "2017/11/11 11:11:11PM"
922 valid4 = "2017/11/10 09:08:07 PM"
923 valid5 = "never"
924 invalid1 = "abc"
926 cat >expect <<-EOF &&
927 $(test-tool date timestamp $rel)
928 1275666415
929 1510441871
930 1510348087
933 : "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
935 echo "$rel_out $(git config --expiry-date date.valid1)" &&
936 git config --expiry-date date.valid2 &&
937 git config --expiry-date date.valid3 &&
938 git config --expiry-date date.valid4 &&
939 git config --expiry-date date.valid5
940 } >actual &&
941 test_cmp expect actual &&
942 test_must_fail git config --expiry-date date.invalid1
945 test_expect_success 'get --type=color' '
946 rm .git/config &&
947 git config foo.color "red" &&
948 git config --get --type=color foo.color >actual.raw &&
949 test_decode_color <actual.raw >actual &&
950 echo "<RED>" >expect &&
951 test_cmp expect actual
954 cat >expect << EOF
955 [foo]
956 color = red
959 test_expect_success 'set --type=color' '
960 rm .git/config &&
961 git config --type=color foo.color "red" &&
962 test_cmp expect .git/config
965 test_expect_success 'get --type=color barfs on non-color' '
966 echo "[foo]bar=not-a-color" >.git/config &&
967 test_must_fail git config --get --type=color foo.bar
970 test_expect_success 'set --type=color barfs on non-color' '
971 test_must_fail git config --type=color foo.color "not-a-color" 2>error &&
972 test_i18ngrep "cannot parse color" error
975 cat > expect << EOF
976 [quote]
977 leading = " test"
978 ending = "test "
979 semicolon = "test;test"
980 hash = "test#test"
982 test_expect_success 'quoting' '
983 rm -f .git/config &&
984 git config quote.leading " test" &&
985 git config quote.ending "test " &&
986 git config quote.semicolon "test;test" &&
987 git config quote.hash "test#test" &&
988 test_cmp expect .git/config
991 test_expect_success 'key with newline' '
992 test_must_fail git config "key.with
993 newline" 123'
995 test_expect_success 'value with newline' 'git config key.sub value.with\\\
996 newline'
998 cat > .git/config <<\EOF
999 [section]
1000 ; comment \
1001 continued = cont\
1002 inued
1003 noncont = not continued ; \
1004 quotecont = "cont;\
1005 inued"
1008 cat > expect <<\EOF
1009 section.continued=continued
1010 section.noncont=not continued
1011 section.quotecont=cont;inued
1014 test_expect_success 'value continued on next line' '
1015 git config --list > result &&
1016 test_cmp expect result
1019 cat > .git/config <<\EOF
1020 [section "sub=section"]
1021 val1 = foo=bar
1022 val2 = foo\nbar
1023 val3 = \n\n
1024 val4 =
1025 val5
1028 cat > expect <<\EOF
1029 section.sub=section.val1
1030 foo=barQsection.sub=section.val2
1032 barQsection.sub=section.val3
1035 Qsection.sub=section.val4
1036 Qsection.sub=section.val5Q
1038 test_expect_success '--null --list' '
1039 git config --null --list >result.raw &&
1040 nul_to_q <result.raw >result &&
1041 echo >>result &&
1042 test_cmp expect result
1045 test_expect_success '--null --get-regexp' '
1046 git config --null --get-regexp "val[0-9]" >result.raw &&
1047 nul_to_q <result.raw >result &&
1048 echo >>result &&
1049 test_cmp expect result
1052 test_expect_success 'inner whitespace kept verbatim' '
1053 git config section.val "foo bar" &&
1054 test_cmp_config "foo bar" section.val
1057 test_expect_success SYMLINKS 'symlinked configuration' '
1058 ln -s notyet myconfig &&
1059 git config --file=myconfig test.frotz nitfol &&
1060 test -h myconfig &&
1061 test -f notyet &&
1062 test "z$(git config --file=notyet test.frotz)" = znitfol &&
1063 git config --file=myconfig test.xyzzy rezrov &&
1064 test -h myconfig &&
1065 test -f notyet &&
1066 cat >expect <<-\EOF &&
1067 nitfol
1068 rezrov
1071 git config --file=notyet test.frotz &&
1072 git config --file=notyet test.xyzzy
1073 } >actual &&
1074 test_cmp expect actual
1077 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
1078 ln -s doesnotexist linktonada &&
1079 ln -s linktonada linktolinktonada &&
1080 test_must_fail git config --file=linktonada --list &&
1081 test_must_fail git config --file=linktolinktonada --list
1084 test_expect_success 'check split_cmdline return' "
1085 git config alias.split-cmdline-fix 'echo \"' &&
1086 test_must_fail git split-cmdline-fix &&
1087 echo foo > foo &&
1088 git add foo &&
1089 git commit -m 'initial commit' &&
1090 git config branch.main.mergeoptions 'echo \"' &&
1091 test_must_fail git merge main
1094 test_expect_success 'git -c "key=value" support' '
1095 cat >expect <<-\EOF &&
1096 value
1097 value
1098 true
1101 git -c section.name=value config section.name &&
1102 git -c foo.CamelCase=value config foo.camelcase &&
1103 git -c foo.flag config --bool foo.flag
1104 } >actual &&
1105 test_cmp expect actual &&
1106 test_must_fail git -c name=value config section.name
1109 # We just need a type-specifier here that cares about the
1110 # distinction internally between a NULL boolean and a real
1111 # string (because most of git's internal parsers do care).
1112 # Using "--path" works, but we do not otherwise care about
1113 # its semantics.
1114 test_expect_success 'git -c can represent empty string' '
1115 echo >expect &&
1116 git -c foo.empty= config --path foo.empty >actual &&
1117 test_cmp expect actual
1120 test_expect_success 'key sanity-checking' '
1121 test_must_fail git config foo=bar &&
1122 test_must_fail git config foo=.bar &&
1123 test_must_fail git config foo.ba=r &&
1124 test_must_fail git config foo.1bar &&
1125 test_must_fail git config foo."ba
1126 z".bar &&
1127 test_must_fail git config . false &&
1128 test_must_fail git config .foo false &&
1129 test_must_fail git config foo. false &&
1130 test_must_fail git config .foo. false &&
1131 git config foo.bar true &&
1132 git config foo."ba =z".bar false
1135 test_expect_success 'git -c works with aliases of builtins' '
1136 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
1137 echo bar >expect &&
1138 git checkconfig >actual &&
1139 test_cmp expect actual
1142 test_expect_success 'aliases can be CamelCased' '
1143 test_config alias.CamelCased "rev-parse HEAD" &&
1144 git CamelCased >out &&
1145 git rev-parse HEAD >expect &&
1146 test_cmp expect out
1149 test_expect_success 'git -c does not split values on equals' '
1150 echo "value with = in it" >expect &&
1151 git -c section.foo="value with = in it" config section.foo >actual &&
1152 test_cmp expect actual
1155 test_expect_success 'git -c dies on bogus config' '
1156 test_must_fail git -c core.bare=foo rev-parse
1159 test_expect_success 'git -c complains about empty key' '
1160 test_must_fail git -c "=foo" rev-parse
1163 test_expect_success 'git -c complains about empty key and value' '
1164 test_must_fail git -c "" rev-parse
1167 test_expect_success 'multiple git -c appends config' '
1168 test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
1169 cat >expect <<-\EOF &&
1170 x.one 1
1171 x.two 2
1173 git -c x.one=1 x >actual &&
1174 test_cmp expect actual
1177 test_expect_success 'last one wins: two level vars' '
1179 # sec.var and sec.VAR are the same variable, as the first
1180 # and the last level of a configuration variable name is
1181 # case insensitive.
1183 echo VAL >expect &&
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 &&
1190 git -c sec.var=val -c sec.VAR=VAL config --get SEC.var >actual &&
1191 test_cmp expect actual &&
1192 git -c SEC.var=val -c sec.var=VAL config --get sec.VAR >actual &&
1193 test_cmp expect actual
1196 test_expect_success 'last one wins: three level vars' '
1198 # v.a.r and v.A.r are not the same variable, as the middle
1199 # level of a three-level configuration variable name is
1200 # case sensitive.
1202 echo val >expect &&
1203 git -c v.a.r=val -c v.A.r=VAL config --get v.a.r >actual &&
1204 test_cmp expect actual &&
1205 git -c v.a.r=val -c v.A.r=VAL config --get V.a.R >actual &&
1206 test_cmp expect actual &&
1208 # v.a.r and V.a.R are the same variable, as the first
1209 # and the last level of a configuration variable name is
1210 # case insensitive.
1212 echo VAL >expect &&
1213 git -c v.a.r=val -c v.a.R=VAL config --get v.a.r >actual &&
1214 test_cmp expect actual &&
1215 git -c v.a.r=val -c V.a.r=VAL config --get v.a.r >actual &&
1216 test_cmp expect actual &&
1217 git -c v.a.r=val -c v.a.R=VAL config --get V.a.R >actual &&
1218 test_cmp expect actual &&
1219 git -c v.a.r=val -c V.a.r=VAL config --get V.a.R >actual &&
1220 test_cmp expect actual
1223 test_expect_success 'old-fashioned settings are case insensitive' '
1224 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1226 cat >testConfig_actual <<-EOF &&
1227 [V.A]
1228 r = value1
1230 q_to_tab >testConfig_expect <<-EOF &&
1231 [V.A]
1232 Qr = value2
1234 git config -f testConfig_actual "v.a.r" value2 &&
1235 test_cmp testConfig_expect testConfig_actual &&
1237 cat >testConfig_actual <<-EOF &&
1238 [V.A]
1239 r = value1
1241 q_to_tab >testConfig_expect <<-EOF &&
1242 [V.A]
1243 QR = value2
1245 git config -f testConfig_actual "V.a.R" value2 &&
1246 test_cmp testConfig_expect testConfig_actual &&
1248 cat >testConfig_actual <<-EOF &&
1249 [V.A]
1250 r = value1
1252 q_to_tab >testConfig_expect <<-EOF &&
1253 [V.A]
1254 r = value1
1255 Qr = value2
1257 git config -f testConfig_actual "V.A.r" value2 &&
1258 test_cmp testConfig_expect testConfig_actual &&
1260 cat >testConfig_actual <<-EOF &&
1261 [V.A]
1262 r = value1
1264 q_to_tab >testConfig_expect <<-EOF &&
1265 [V.A]
1266 r = value1
1267 Qr = value2
1269 git config -f testConfig_actual "v.A.r" value2 &&
1270 test_cmp testConfig_expect testConfig_actual
1273 test_expect_success 'setting different case sensitive subsections ' '
1274 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1276 cat >testConfig_actual <<-EOF &&
1277 [V "A"]
1278 R = v1
1279 [K "E"]
1280 Y = v1
1281 [a "b"]
1282 c = v1
1283 [d "e"]
1284 f = v1
1286 q_to_tab >testConfig_expect <<-EOF &&
1287 [V "A"]
1288 Qr = v2
1289 [K "E"]
1290 Qy = v2
1291 [a "b"]
1292 Qc = v2
1293 [d "e"]
1294 f = v1
1295 [d "E"]
1296 Qf = v2
1298 # exact match
1299 git config -f testConfig_actual a.b.c v2 &&
1300 # match section and subsection, key is cased differently.
1301 git config -f testConfig_actual K.E.y v2 &&
1302 # section and key are matched case insensitive, but subsection needs
1303 # to match; When writing out new values only the key is adjusted
1304 git config -f testConfig_actual v.A.r v2 &&
1305 # subsection is not matched:
1306 git config -f testConfig_actual d.E.f v2 &&
1307 test_cmp testConfig_expect testConfig_actual
1310 for VAR in a .a a. a.0b a."b c". a."b c".0d
1312 test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" '
1313 test_must_fail git -c "$VAR=VAL" config -l
1315 done
1317 for VAR in a.b a."b c".d
1319 test_expect_success "git -c $VAR=VAL works with valid '$VAR'" '
1320 echo VAL >expect &&
1321 git -c "$VAR=VAL" config --get "$VAR" >actual &&
1322 test_cmp expect actual
1324 done
1326 test_expect_success 'git -c is not confused by empty environment' '
1327 GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
1330 test_expect_success 'GIT_CONFIG_PARAMETERS handles old-style entries' '
1331 v="${SQ}key.one=foo${SQ}" &&
1332 v="$v ${SQ}key.two=bar${SQ}" &&
1333 v="$v ${SQ}key.ambiguous=section.whatever=value${SQ}" &&
1334 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1335 cat >expect <<-EOF &&
1336 key.one foo
1337 key.two bar
1338 key.ambiguous section.whatever=value
1340 test_cmp expect actual
1343 test_expect_success 'GIT_CONFIG_PARAMETERS handles new-style entries' '
1344 v="${SQ}key.one${SQ}=${SQ}foo${SQ}" &&
1345 v="$v ${SQ}key.two${SQ}=${SQ}bar${SQ}" &&
1346 v="$v ${SQ}key.ambiguous=section.whatever${SQ}=${SQ}value${SQ}" &&
1347 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1348 cat >expect <<-EOF &&
1349 key.one foo
1350 key.two bar
1351 key.ambiguous=section.whatever value
1353 test_cmp expect actual
1356 test_expect_success 'old and new-style entries can mix' '
1357 v="${SQ}key.oldone=oldfoo${SQ}" &&
1358 v="$v ${SQ}key.newone${SQ}=${SQ}newfoo${SQ}" &&
1359 v="$v ${SQ}key.oldtwo=oldbar${SQ}" &&
1360 v="$v ${SQ}key.newtwo${SQ}=${SQ}newbar${SQ}" &&
1361 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1362 cat >expect <<-EOF &&
1363 key.oldone oldfoo
1364 key.newone newfoo
1365 key.oldtwo oldbar
1366 key.newtwo newbar
1368 test_cmp expect actual
1371 test_expect_success 'old and new bools with ambiguous subsection' '
1372 v="${SQ}key.with=equals.oldbool${SQ}" &&
1373 v="$v ${SQ}key.with=equals.newbool${SQ}=" &&
1374 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1375 cat >expect <<-EOF &&
1376 key.with equals.oldbool
1377 key.with=equals.newbool
1379 test_cmp expect actual
1382 test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
1383 cat >expect <<-\EOF &&
1384 env.one one
1385 env.two two
1387 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \
1388 git config --get-regexp "env.*" >actual &&
1389 test_cmp expect actual &&
1391 cat >expect <<-EOF &&
1392 env.one one${SQ}
1393 env.two two
1395 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \
1396 git config --get-regexp "env.*" >actual &&
1397 test_cmp expect actual &&
1399 test_must_fail env \
1400 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \
1401 git config --get-regexp "env.*"
1404 test_expect_success 'git --config-env=key=envvar support' '
1405 cat >expect <<-\EOF &&
1406 value
1407 value
1408 value
1409 value
1410 false
1411 false
1414 ENVVAR=value git --config-env=core.name=ENVVAR config core.name &&
1415 ENVVAR=value git --config-env core.name=ENVVAR config core.name &&
1416 ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase &&
1417 ENVVAR=value git --config-env foo.CamelCase=ENVVAR config foo.camelcase &&
1418 ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag &&
1419 ENVVAR= git --config-env foo.flag=ENVVAR config --bool foo.flag
1420 } >actual &&
1421 test_cmp expect actual
1424 test_expect_success 'git --config-env with missing value' '
1425 test_must_fail env ENVVAR=value git --config-env 2>error &&
1426 grep "no config key given for --config-env" error &&
1427 test_must_fail env ENVVAR=value git --config-env config core.name 2>error &&
1428 grep "invalid config format: config" error
1431 test_expect_success 'git --config-env fails with invalid parameters' '
1432 test_must_fail git --config-env=foo.flag config --bool foo.flag 2>error &&
1433 test_i18ngrep "invalid config format: foo.flag" error &&
1434 test_must_fail git --config-env=foo.flag= config --bool foo.flag 2>error &&
1435 test_i18ngrep "missing environment variable name for configuration ${SQ}foo.flag${SQ}" error &&
1436 sane_unset NONEXISTENT &&
1437 test_must_fail git --config-env=foo.flag=NONEXISTENT config --bool foo.flag 2>error &&
1438 test_i18ngrep "missing environment variable ${SQ}NONEXISTENT${SQ} for configuration ${SQ}foo.flag${SQ}" error
1441 test_expect_success 'git -c and --config-env work together' '
1442 cat >expect <<-\EOF &&
1443 bar.cmd cmd-value
1444 bar.env env-value
1446 ENVVAR=env-value git \
1447 -c bar.cmd=cmd-value \
1448 --config-env=bar.env=ENVVAR \
1449 config --get-regexp "^bar.*" >actual &&
1450 test_cmp expect actual
1453 test_expect_success 'git -c and --config-env override each other' '
1454 cat >expect <<-\EOF &&
1459 ENVVAR=env git -c bar.bar=cmd --config-env=bar.bar=ENVVAR config bar.bar &&
1460 ENVVAR=env git --config-env=bar.bar=ENVVAR -c bar.bar=cmd config bar.bar
1461 } >actual &&
1462 test_cmp expect actual
1465 test_expect_success '--config-env handles keys with equals' '
1466 echo value=with=equals >expect &&
1467 ENVVAR=value=with=equals git \
1468 --config-env=section.subsection=with=equals.key=ENVVAR \
1469 config section.subsection=with=equals.key >actual &&
1470 test_cmp expect actual
1473 test_expect_success 'git config handles environment config pairs' '
1474 GIT_CONFIG_COUNT=2 \
1475 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="foo" \
1476 GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="bar" \
1477 git config --get-regexp "pair.*" >actual &&
1478 cat >expect <<-EOF &&
1479 pair.one foo
1480 pair.two bar
1482 test_cmp expect actual
1485 test_expect_success 'git config ignores pairs without count' '
1486 test_must_fail env GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1487 git config pair.one 2>error &&
1488 test_must_be_empty error
1491 test_expect_success 'git config ignores pairs with zero count' '
1492 test_must_fail env \
1493 GIT_CONFIG_COUNT=0 \
1494 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1495 git config pair.one
1498 test_expect_success 'git config ignores pairs exceeding count' '
1499 GIT_CONFIG_COUNT=1 \
1500 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1501 GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
1502 git config --get-regexp "pair.*" >actual &&
1503 cat >expect <<-EOF &&
1504 pair.one value
1506 test_cmp expect actual
1509 test_expect_success 'git config ignores pairs with zero count' '
1510 test_must_fail env \
1511 GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1512 git config pair.one >error &&
1513 test_must_be_empty error
1516 test_expect_success 'git config ignores pairs with empty count' '
1517 test_must_fail env \
1518 GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1519 git config pair.one >error &&
1520 test_must_be_empty error
1523 test_expect_success 'git config fails with invalid count' '
1524 test_must_fail env GIT_CONFIG_COUNT=10a git config --list 2>error &&
1525 test_i18ngrep "bogus count" error &&
1526 test_must_fail env GIT_CONFIG_COUNT=9999999999999999 git config --list 2>error &&
1527 test_i18ngrep "too many entries" error
1530 test_expect_success 'git config fails with missing config key' '
1531 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_VALUE_0="value" \
1532 git config --list 2>error &&
1533 test_i18ngrep "missing config key" error
1536 test_expect_success 'git config fails with missing config value' '
1537 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="pair.one" \
1538 git config --list 2>error &&
1539 test_i18ngrep "missing config value" error
1542 test_expect_success 'git config fails with invalid config pair key' '
1543 test_must_fail env GIT_CONFIG_COUNT=1 \
1544 GIT_CONFIG_KEY_0= GIT_CONFIG_VALUE_0=value \
1545 git config --list &&
1546 test_must_fail env GIT_CONFIG_COUNT=1 \
1547 GIT_CONFIG_KEY_0=missing-section GIT_CONFIG_VALUE_0=value \
1548 git config --list
1551 test_expect_success 'environment overrides config file' '
1552 test_when_finished "rm -f .git/config" &&
1553 cat >.git/config <<-EOF &&
1554 [pair]
1555 one = value
1557 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=override \
1558 git config pair.one >actual &&
1559 cat >expect <<-EOF &&
1560 override
1562 test_cmp expect actual
1565 test_expect_success 'GIT_CONFIG_PARAMETERS overrides environment config' '
1566 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \
1567 GIT_CONFIG_PARAMETERS="${SQ}pair.one=override${SQ}" \
1568 git config pair.one >actual &&
1569 cat >expect <<-EOF &&
1570 override
1572 test_cmp expect actual
1575 test_expect_success 'command line overrides environment config' '
1576 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \
1577 git -c pair.one=override config pair.one >actual &&
1578 cat >expect <<-EOF &&
1579 override
1581 test_cmp expect actual
1584 test_expect_success 'git config --edit works' '
1585 git config -f tmp test.value no &&
1586 echo test.value=yes >expect &&
1587 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1588 git config -f tmp --list >actual &&
1589 test_cmp expect actual
1592 test_expect_success 'git config --edit respects core.editor' '
1593 git config -f tmp test.value no &&
1594 echo test.value=yes >expect &&
1595 test_config core.editor "echo [test]value=yes >" &&
1596 git config -f tmp --edit &&
1597 git config -f tmp --list >actual &&
1598 test_cmp expect actual
1601 # malformed configuration files
1602 test_expect_success 'barf on syntax error' '
1603 cat >.git/config <<-\EOF &&
1604 # broken section line
1605 [section]
1606 key garbage
1608 test_must_fail git config --get section.key >actual 2>error &&
1609 test_i18ngrep " line 3 " error
1612 test_expect_success 'barf on incomplete section header' '
1613 cat >.git/config <<-\EOF &&
1614 # broken section line
1615 [section
1616 key = value
1618 test_must_fail git config --get section.key >actual 2>error &&
1619 test_i18ngrep " line 2 " error
1622 test_expect_success 'barf on incomplete string' '
1623 cat >.git/config <<-\EOF &&
1624 # broken section line
1625 [section]
1626 key = "value string
1628 test_must_fail git config --get section.key >actual 2>error &&
1629 test_i18ngrep " line 3 " error
1632 test_expect_success 'urlmatch' '
1633 cat >.git/config <<-\EOF &&
1634 [http]
1635 sslVerify
1636 [http "https://weak.example.com"]
1637 sslVerify = false
1638 cookieFile = /tmp/cookie.txt
1641 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1642 test_must_be_empty actual &&
1644 echo true >expect &&
1645 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
1646 test_cmp expect actual &&
1648 echo false >expect &&
1649 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual &&
1650 test_cmp expect actual &&
1653 echo http.cookiefile /tmp/cookie.txt &&
1654 echo http.sslverify false
1655 } >expect &&
1656 git config --get-urlmatch HTTP https://weak.example.com >actual &&
1657 test_cmp expect actual
1660 test_expect_success 'urlmatch favors more specific URLs' '
1661 cat >.git/config <<-\EOF &&
1662 [http "https://example.com/"]
1663 cookieFile = /tmp/root.txt
1664 [http "https://example.com/subdirectory"]
1665 cookieFile = /tmp/subdirectory.txt
1666 [http "https://user@example.com/"]
1667 cookieFile = /tmp/user.txt
1668 [http "https://averylonguser@example.com/"]
1669 cookieFile = /tmp/averylonguser.txt
1670 [http "https://preceding.example.com"]
1671 cookieFile = /tmp/preceding.txt
1672 [http "https://*.example.com"]
1673 cookieFile = /tmp/wildcard.txt
1674 [http "https://*.example.com/wildcardwithsubdomain"]
1675 cookieFile = /tmp/wildcardwithsubdomain.txt
1676 [http "https://*.example.*"]
1677 cookieFile = /tmp/multiwildcard.txt
1678 [http "https://trailing.example.com"]
1679 cookieFile = /tmp/trailing.txt
1680 [http "https://user@*.example.com/"]
1681 cookieFile = /tmp/wildcardwithuser.txt
1682 [http "https://sub.example.com/"]
1683 cookieFile = /tmp/sub.txt
1686 echo http.cookiefile /tmp/root.txt >expect &&
1687 git config --get-urlmatch HTTP https://example.com >actual &&
1688 test_cmp expect actual &&
1690 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1691 git config --get-urlmatch HTTP https://example.com/subdirectory >actual &&
1692 test_cmp expect actual &&
1694 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1695 git config --get-urlmatch HTTP https://example.com/subdirectory/nested >actual &&
1696 test_cmp expect actual &&
1698 echo http.cookiefile /tmp/user.txt >expect &&
1699 git config --get-urlmatch HTTP https://user@example.com/ >actual &&
1700 test_cmp expect actual &&
1702 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1703 git config --get-urlmatch HTTP https://averylonguser@example.com/subdirectory >actual &&
1704 test_cmp expect actual &&
1706 echo http.cookiefile /tmp/preceding.txt >expect &&
1707 git config --get-urlmatch HTTP https://preceding.example.com >actual &&
1708 test_cmp expect actual &&
1710 echo http.cookiefile /tmp/wildcard.txt >expect &&
1711 git config --get-urlmatch HTTP https://wildcard.example.com >actual &&
1712 test_cmp expect actual &&
1714 echo http.cookiefile /tmp/sub.txt >expect &&
1715 git config --get-urlmatch HTTP https://sub.example.com/wildcardwithsubdomain >actual &&
1716 test_cmp expect actual &&
1718 echo http.cookiefile /tmp/trailing.txt >expect &&
1719 git config --get-urlmatch HTTP https://trailing.example.com >actual &&
1720 test_cmp expect actual &&
1722 echo http.cookiefile /tmp/sub.txt >expect &&
1723 git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
1724 test_cmp expect actual &&
1726 echo http.cookiefile /tmp/multiwildcard.txt >expect &&
1727 git config --get-urlmatch HTTP https://wildcard.example.org >actual &&
1728 test_cmp expect actual
1731 test_expect_success 'urlmatch with wildcard' '
1732 cat >.git/config <<-\EOF &&
1733 [http]
1734 sslVerify
1735 [http "https://*.example.com"]
1736 sslVerify = false
1737 cookieFile = /tmp/cookie.txt
1740 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1741 test_must_be_empty actual &&
1743 echo true >expect &&
1744 git config --bool --get-urlmatch http.SSLverify https://example.com >actual &&
1745 test_cmp expect actual &&
1747 echo true >expect &&
1748 git config --bool --get-urlmatch http.SSLverify https://good-example.com >actual &&
1749 test_cmp expect actual &&
1751 echo true >expect &&
1752 git config --bool --get-urlmatch http.sslverify https://deep.nested.example.com >actual &&
1753 test_cmp expect actual &&
1755 echo false >expect &&
1756 git config --bool --get-urlmatch http.sslverify https://good.example.com >actual &&
1757 test_cmp expect actual &&
1760 echo http.cookiefile /tmp/cookie.txt &&
1761 echo http.sslverify false
1762 } >expect &&
1763 git config --get-urlmatch HTTP https://good.example.com >actual &&
1764 test_cmp expect actual &&
1766 echo http.sslverify >expect &&
1767 git config --get-urlmatch HTTP https://more.example.com.au >actual &&
1768 test_cmp expect actual
1771 # good section hygiene
1772 test_expect_success '--unset last key removes section (except if commented)' '
1773 cat >.git/config <<-\EOF &&
1774 # some generic comment on the configuration file itself
1775 # a comment specific to this "section" section.
1776 [section]
1777 # some intervening lines
1778 # that should also be dropped
1780 key = value
1781 # please be careful when you update the above variable
1784 cat >expect <<-\EOF &&
1785 # some generic comment on the configuration file itself
1786 # a comment specific to this "section" section.
1787 [section]
1788 # some intervening lines
1789 # that should also be dropped
1791 # please be careful when you update the above variable
1794 git config --unset section.key &&
1795 test_cmp expect .git/config &&
1797 cat >.git/config <<-\EOF &&
1798 [section]
1799 key = value
1800 [next-section]
1803 cat >expect <<-\EOF &&
1804 [next-section]
1807 git config --unset section.key &&
1808 test_cmp expect .git/config &&
1810 q_to_tab >.git/config <<-\EOF &&
1811 [one]
1812 Qkey = "multiline \
1813 QQ# with comment"
1814 [two]
1815 key = true
1817 git config --unset two.key &&
1818 ! grep two .git/config &&
1820 q_to_tab >.git/config <<-\EOF &&
1821 [one]
1822 Qkey = "multiline \
1823 QQ# with comment"
1824 [one]
1825 key = true
1827 git config --unset-all one.key &&
1828 test_line_count = 0 .git/config &&
1830 q_to_tab >.git/config <<-\EOF &&
1831 [one]
1832 Qkey = true
1833 Q# a comment not at the start
1834 [two]
1835 Qkey = true
1837 git config --unset two.key &&
1838 grep two .git/config &&
1840 q_to_tab >.git/config <<-\EOF &&
1841 [one]
1842 Qkey = not [two "subsection"]
1843 [two "subsection"]
1844 [two "subsection"]
1845 Qkey = true
1846 [TWO "subsection"]
1847 [one]
1849 git config --unset two.subsection.key &&
1850 test "not [two subsection]" = "$(git config one.key)" &&
1851 test_line_count = 3 .git/config
1854 test_expect_success '--unset-all removes section if empty & uncommented' '
1855 cat >.git/config <<-\EOF &&
1856 [section]
1857 key = value1
1858 key = value2
1861 git config --unset-all section.key &&
1862 test_line_count = 0 .git/config
1865 test_expect_success 'adding a key into an empty section reuses header' '
1866 cat >.git/config <<-\EOF &&
1867 [section]
1870 q_to_tab >expect <<-\EOF &&
1871 [section]
1872 Qkey = value
1875 git config section.key value &&
1876 test_cmp expect .git/config
1879 test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
1880 chmod 0600 .git/config &&
1881 git config imap.pass Hunter2 &&
1882 perl -e \
1883 "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
1884 git config --rename-section imap pop &&
1885 perl -e \
1886 "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
1889 ! test_have_prereq MINGW ||
1890 HOME="$(pwd)" # convert to Windows path
1892 test_expect_success 'set up --show-origin tests' '
1893 INCLUDE_DIR="$HOME/include" &&
1894 mkdir -p "$INCLUDE_DIR" &&
1895 cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
1896 [user]
1897 absolute = include
1899 cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
1900 [user]
1901 relative = include
1903 cat >"$HOME"/.gitconfig <<-EOF &&
1904 [user]
1905 global = true
1906 override = global
1907 [include]
1908 path = "$INCLUDE_DIR/absolute.include"
1910 cat >.git/config <<-\EOF
1911 [user]
1912 local = true
1913 override = local
1914 [include]
1915 path = ../include/relative.include
1919 test_expect_success '--show-origin with --list' '
1920 cat >expect <<-EOF &&
1921 file:$HOME/.gitconfig user.global=true
1922 file:$HOME/.gitconfig user.override=global
1923 file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
1924 file:$INCLUDE_DIR/absolute.include user.absolute=include
1925 file:.git/config user.local=true
1926 file:.git/config user.override=local
1927 file:.git/config include.path=../include/relative.include
1928 file:.git/../include/relative.include user.relative=include
1929 command line: user.environ=true
1930 command line: user.cmdline=true
1932 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.environ GIT_CONFIG_VALUE_0=true\
1933 git -c user.cmdline=true config --list --show-origin >output &&
1934 test_cmp expect output
1937 test_expect_success '--show-origin with --list --null' '
1938 cat >expect <<-EOF &&
1939 file:$HOME/.gitconfigQuser.global
1940 trueQfile:$HOME/.gitconfigQuser.override
1941 globalQfile:$HOME/.gitconfigQinclude.path
1942 $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
1943 includeQfile:.git/configQuser.local
1944 trueQfile:.git/configQuser.override
1945 localQfile:.git/configQinclude.path
1946 ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
1947 includeQcommand line:Quser.cmdline
1948 trueQ
1950 git -c user.cmdline=true config --null --list --show-origin >output.raw &&
1951 nul_to_q <output.raw >output &&
1952 # The here-doc above adds a newline that the --null output would not
1953 # include. Add it here to make the two comparable.
1954 echo >>output &&
1955 test_cmp expect output
1958 test_expect_success '--show-origin with single file' '
1959 cat >expect <<-\EOF &&
1960 file:.git/config user.local=true
1961 file:.git/config user.override=local
1962 file:.git/config include.path=../include/relative.include
1964 git config --local --list --show-origin >output &&
1965 test_cmp expect output
1968 test_expect_success '--show-origin with --get-regexp' '
1969 cat >expect <<-EOF &&
1970 file:$HOME/.gitconfig user.global true
1971 file:.git/config user.local true
1973 git config --show-origin --get-regexp "user\.[g|l].*" >output &&
1974 test_cmp expect output
1977 test_expect_success '--show-origin getting a single key' '
1978 cat >expect <<-\EOF &&
1979 file:.git/config local
1981 git config --show-origin user.override >output &&
1982 test_cmp expect output
1985 test_expect_success 'set up custom config file' '
1986 CUSTOM_CONFIG_FILE="custom.conf" &&
1987 cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
1988 [user]
1989 custom = true
1993 test_expect_success !MINGW 'set up custom config file with special name characters' '
1994 WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" &&
1995 cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE"
1998 test_expect_success !MINGW '--show-origin escape special file name characters' '
1999 cat >expect <<-\EOF &&
2000 file:"file\" (dq) and spaces.conf" user.custom=true
2002 git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
2003 test_cmp expect output
2006 test_expect_success '--show-origin stdin' '
2007 cat >expect <<-\EOF &&
2008 standard input: user.custom=true
2010 git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
2011 test_cmp expect output
2014 test_expect_success '--show-origin stdin with file include' '
2015 cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
2016 [user]
2017 stdin = include
2019 cat >expect <<-EOF &&
2020 file:$INCLUDE_DIR/stdin.include include
2022 echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
2023 git config --show-origin --includes --file - user.stdin >output &&
2025 test_cmp expect output
2028 test_expect_success '--show-origin blob' '
2029 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2030 cat >expect <<-EOF &&
2031 blob:$blob user.custom=true
2033 git config --blob=$blob --show-origin --list >output &&
2034 test_cmp expect output
2037 test_expect_success '--show-origin blob ref' '
2038 cat >expect <<-\EOF &&
2039 blob:main:custom.conf user.custom=true
2041 git add "$CUSTOM_CONFIG_FILE" &&
2042 git commit -m "new config file" &&
2043 git config --blob=main:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
2044 test_cmp expect output
2047 test_expect_success '--show-scope with --list' '
2048 cat >expect <<-EOF &&
2049 global user.global=true
2050 global user.override=global
2051 global include.path=$INCLUDE_DIR/absolute.include
2052 global user.absolute=include
2053 local user.local=true
2054 local user.override=local
2055 local include.path=../include/relative.include
2056 local user.relative=include
2057 command user.cmdline=true
2059 git -c user.cmdline=true config --list --show-scope >output &&
2060 test_cmp expect output
2063 test_expect_success !MINGW '--show-scope with --blob' '
2064 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2065 cat >expect <<-EOF &&
2066 command user.custom=true
2068 git config --blob=$blob --show-scope --list >output &&
2069 test_cmp expect output
2072 test_expect_success '--show-scope with --local' '
2073 cat >expect <<-\EOF &&
2074 local user.local=true
2075 local user.override=local
2076 local include.path=../include/relative.include
2078 git config --local --list --show-scope >output &&
2079 test_cmp expect output
2082 test_expect_success '--show-scope getting a single value' '
2083 cat >expect <<-\EOF &&
2084 local true
2086 git config --show-scope --get user.local >output &&
2087 test_cmp expect output
2090 test_expect_success '--show-scope with --show-origin' '
2091 cat >expect <<-EOF &&
2092 global file:$HOME/.gitconfig user.global=true
2093 global file:$HOME/.gitconfig user.override=global
2094 global file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
2095 global file:$INCLUDE_DIR/absolute.include user.absolute=include
2096 local file:.git/config user.local=true
2097 local file:.git/config user.override=local
2098 local file:.git/config include.path=../include/relative.include
2099 local file:.git/../include/relative.include user.relative=include
2100 command command line: user.cmdline=true
2102 git -c user.cmdline=true config --list --show-origin --show-scope >output &&
2103 test_cmp expect output
2106 test_expect_success 'override global and system config' '
2107 test_when_finished rm -f "$HOME"/.config/git &&
2109 cat >"$HOME"/.gitconfig <<-EOF &&
2110 [home]
2111 config = true
2113 mkdir -p "$HOME"/.config/git &&
2114 cat >"$HOME"/.config/git/config <<-EOF &&
2115 [xdg]
2116 config = true
2118 cat >.git/config <<-EOF &&
2119 [local]
2120 config = true
2122 cat >custom-global-config <<-EOF &&
2123 [global]
2124 config = true
2126 cat >custom-system-config <<-EOF &&
2127 [system]
2128 config = true
2131 cat >expect <<-EOF &&
2132 global xdg.config=true
2133 global home.config=true
2134 local local.config=true
2136 git config --show-scope --list >output &&
2137 test_cmp expect output &&
2139 cat >expect <<-EOF &&
2140 system system.config=true
2141 global global.config=true
2142 local local.config=true
2144 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
2145 git config --show-scope --list >output &&
2146 test_cmp expect output &&
2148 cat >expect <<-EOF &&
2149 local local.config=true
2151 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \
2152 git config --show-scope --list >output &&
2153 test_cmp expect output
2156 test_expect_success 'override global and system config with missing file' '
2157 test_must_fail env GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=/dev/null git config --global --list &&
2158 test_must_fail env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=does-not-exist git config --system --list &&
2159 GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=does-not-exist git version
2162 test_expect_success 'system override has no effect with GIT_CONFIG_NOSYSTEM' '
2163 # `git config --system` has different semantics compared to other
2164 # commands as it ignores GIT_CONFIG_NOSYSTEM. We thus test whether the
2165 # variable has an effect via a different proxy.
2166 cat >alias-config <<-EOF &&
2167 [alias]
2168 hello-world = !echo "hello world"
2170 test_must_fail env GIT_CONFIG_NOSYSTEM=true GIT_CONFIG_SYSTEM=alias-config \
2171 git hello-world &&
2172 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=alias-config \
2173 git hello-world >actual &&
2174 echo "hello world" >expect &&
2175 test_cmp expect actual
2178 test_expect_success 'write to overridden global and system config' '
2179 cat >expect <<EOF &&
2180 [config]
2181 key = value
2184 GIT_CONFIG_GLOBAL=write-to-global git config --global config.key value &&
2185 test_cmp expect write-to-global &&
2187 GIT_CONFIG_SYSTEM=write-to-system git config --system config.key value &&
2188 test_cmp expect write-to-system
2191 for opt in --local --worktree
2193 test_expect_success "$opt requires a repo" '
2194 # we expect 128 to ensure that we do not simply
2195 # fail to find anything and return code "1"
2196 test_expect_code 128 nongit git config $opt foo.bar
2198 done
2200 cat >.git/config <<-\EOF &&
2201 [section]
2202 foo = true
2203 number = 10
2204 big = 1M
2207 test_expect_success 'identical modern --type specifiers are allowed' '
2208 test_cmp_config 1048576 --type=int --type=int section.big
2211 test_expect_success 'identical legacy --type specifiers are allowed' '
2212 test_cmp_config 1048576 --int --int section.big
2215 test_expect_success 'identical mixed --type specifiers are allowed' '
2216 test_cmp_config 1048576 --int --type=int section.big
2219 test_expect_success 'non-identical modern --type specifiers are not allowed' '
2220 test_must_fail git config --type=int --type=bool section.big 2>error &&
2221 test_i18ngrep "only one type at a time" error
2224 test_expect_success 'non-identical legacy --type specifiers are not allowed' '
2225 test_must_fail git config --int --bool section.big 2>error &&
2226 test_i18ngrep "only one type at a time" error
2229 test_expect_success 'non-identical mixed --type specifiers are not allowed' '
2230 test_must_fail git config --type=int --bool section.big 2>error &&
2231 test_i18ngrep "only one type at a time" error
2234 test_expect_success '--type allows valid type specifiers' '
2235 test_cmp_config true --type=bool section.foo
2238 test_expect_success '--no-type unsets type specifiers' '
2239 test_cmp_config 10 --type=bool --no-type section.number
2242 test_expect_success 'unset type specifiers may be reset to conflicting ones' '
2243 test_cmp_config 1048576 --type=bool --no-type --type=int section.big
2246 test_expect_success '--type rejects unknown specifiers' '
2247 test_must_fail git config --type=nonsense section.foo 2>error &&
2248 test_i18ngrep "unrecognized --type argument" error
2251 test_expect_success '--replace-all does not invent newlines' '
2252 q_to_tab >.git/config <<-\EOF &&
2253 [abc]key
2254 QkeepSection
2255 [xyz]
2256 Qkey = 1
2257 [abc]
2258 Qkey = a
2260 q_to_tab >expect <<-\EOF &&
2261 [abc]
2262 QkeepSection
2263 [xyz]
2264 Qkey = 1
2265 [abc]
2266 Qkey = b
2268 git config --replace-all abc.key b &&
2269 test_cmp expect .git/config
2272 test_expect_success 'set all config with value-pattern' '
2273 test_when_finished rm -f config initial &&
2274 git config --file=initial abc.key one &&
2276 # no match => add new entry
2277 cp initial config &&
2278 git config --file=config abc.key two a+ &&
2279 git config --file=config --list >actual &&
2280 cat >expect <<-\EOF &&
2281 abc.key=one
2282 abc.key=two
2284 test_cmp expect actual &&
2286 # multiple matches => failure
2287 test_must_fail git config --file=config abc.key three o+ 2>err &&
2288 test_i18ngrep "has multiple values" err &&
2290 # multiple values, no match => add
2291 git config --file=config abc.key three a+ &&
2292 git config --file=config --list >actual &&
2293 cat >expect <<-\EOF &&
2294 abc.key=one
2295 abc.key=two
2296 abc.key=three
2298 test_cmp expect actual &&
2300 # single match => replace
2301 git config --file=config abc.key four h+ &&
2302 git config --file=config --list >actual &&
2303 cat >expect <<-\EOF &&
2304 abc.key=one
2305 abc.key=two
2306 abc.key=four
2308 test_cmp expect actual
2311 test_expect_success '--replace-all and value-pattern' '
2312 test_when_finished rm -f config &&
2313 git config --file=config --add abc.key one &&
2314 git config --file=config --add abc.key two &&
2315 git config --file=config --add abc.key three &&
2316 git config --file=config --replace-all abc.key four "o+" &&
2317 git config --file=config --list >actual &&
2318 cat >expect <<-\EOF &&
2319 abc.key=four
2320 abc.key=three
2322 test_cmp expect actual
2325 test_expect_success 'refuse --fixed-value for incompatible actions' '
2326 test_when_finished rm -f config &&
2327 git config --file=config dev.null bogus &&
2329 # These modes do not allow --fixed-value at all
2330 test_must_fail git config --file=config --fixed-value --add dev.null bogus &&
2331 test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus &&
2332 test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus &&
2333 test_must_fail git config --file=config --fixed-value --rename-section dev null &&
2334 test_must_fail git config --file=config --fixed-value --remove-section dev &&
2335 test_must_fail git config --file=config --fixed-value --list &&
2336 test_must_fail git config --file=config --fixed-value --get-color dev.null &&
2337 test_must_fail git config --file=config --fixed-value --get-colorbool dev.null &&
2339 # These modes complain when --fixed-value has no value-pattern
2340 test_must_fail git config --file=config --fixed-value dev.null bogus &&
2341 test_must_fail git config --file=config --fixed-value --replace-all dev.null bogus &&
2342 test_must_fail git config --file=config --fixed-value --get dev.null &&
2343 test_must_fail git config --file=config --fixed-value --get-all dev.null &&
2344 test_must_fail git config --file=config --fixed-value --get-regexp "dev.*" &&
2345 test_must_fail git config --file=config --fixed-value --unset dev.null &&
2346 test_must_fail git config --file=config --fixed-value --unset-all dev.null
2349 test_expect_success '--fixed-value uses exact string matching' '
2350 test_when_finished rm -f config initial &&
2351 META="a+b*c?d[e]f.g" &&
2352 git config --file=initial fixed.test "$META" &&
2354 cp initial config &&
2355 git config --file=config fixed.test bogus "$META" &&
2356 git config --file=config --list >actual &&
2357 cat >expect <<-EOF &&
2358 fixed.test=$META
2359 fixed.test=bogus
2361 test_cmp expect actual &&
2363 cp initial config &&
2364 git config --file=config --fixed-value fixed.test bogus "$META" &&
2365 git config --file=config --list >actual &&
2366 cat >expect <<-\EOF &&
2367 fixed.test=bogus
2369 test_cmp expect actual &&
2371 cp initial config &&
2372 test_must_fail git config --file=config --unset fixed.test "$META" &&
2373 git config --file=config --fixed-value --unset fixed.test "$META" &&
2374 test_must_fail git config --file=config fixed.test &&
2376 cp initial config &&
2377 test_must_fail git config --file=config --unset-all fixed.test "$META" &&
2378 git config --file=config --fixed-value --unset-all fixed.test "$META" &&
2379 test_must_fail git config --file=config fixed.test &&
2381 cp initial config &&
2382 git config --file=config --replace-all fixed.test bogus "$META" &&
2383 git config --file=config --list >actual &&
2384 cat >expect <<-EOF &&
2385 fixed.test=$META
2386 fixed.test=bogus
2388 test_cmp expect actual &&
2390 git config --file=config --fixed-value --replace-all fixed.test bogus "$META" &&
2391 git config --file=config --list >actual &&
2392 cat >expect <<-EOF &&
2393 fixed.test=bogus
2394 fixed.test=bogus
2396 test_cmp expect actual
2399 test_expect_success '--get and --get-all with --fixed-value' '
2400 test_when_finished rm -f config &&
2401 META="a+b*c?d[e]f.g" &&
2402 git config --file=config fixed.test bogus &&
2403 git config --file=config --add fixed.test "$META" &&
2405 git config --file=config --get fixed.test bogus &&
2406 test_must_fail git config --file=config --get fixed.test "$META" &&
2407 git config --file=config --get --fixed-value fixed.test "$META" &&
2408 test_must_fail git config --file=config --get --fixed-value fixed.test non-existent &&
2410 git config --file=config --get-all fixed.test bogus &&
2411 test_must_fail git config --file=config --get-all fixed.test "$META" &&
2412 git config --file=config --get-all --fixed-value fixed.test "$META" &&
2413 test_must_fail git config --file=config --get-all --fixed-value fixed.test non-existent &&
2415 git config --file=config --get-regexp fixed+ bogus &&
2416 test_must_fail git config --file=config --get-regexp fixed+ "$META" &&
2417 git config --file=config --get-regexp --fixed-value fixed+ "$META" &&
2418 test_must_fail git config --file=config --get-regexp --fixed-value fixed+ non-existent
2421 test_done