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
14 test_expect_success
'setup whitespace config' '
17 -e "s/X/ /g" >.git/config <<-\EOF
20 | sparse = big XX blue
21 | sparseAndTail = big XX blue $
22 | sparseAndTailQuoted = "big XX blue "
23 | sparseAndBiggerTail = big XX blue X X
24 | sparseAndBiggerTailQuoted = "big XX blue X X"
25 | sparseAndBiggerTailQuotedPlus = "big XX blue X X"X $
26 | headAndTail = Xbig blue $
27 | headAndTailQuoted = "Xbig blue "
28 | headAndTailQuotedPlus = "Xbig blue " $
29 | annotated = big blueX# to be discarded
30 | annotatedQuoted = "big blue"X# to be discarded
34 test_expect_success
'no internal whitespace' '
35 echo "rock" >expect &&
36 git config --get section.solid >actual &&
37 test_cmp expect actual
40 test_expect_success
'internal whitespace' '
41 echo "big QQ blue" | q_to_tab >expect &&
42 git config --get section.sparse >actual &&
43 test_cmp expect actual
46 test_expect_success
'internal and trailing whitespace' '
47 echo "big QQ blue" | q_to_tab >expect &&
48 git config --get section.sparseAndTail >actual &&
49 test_cmp expect actual
52 test_expect_success
'internal and trailing whitespace, all quoted' '
53 echo "big QQ blue " | q_to_tab >expect &&
54 git config --get section.sparseAndTailQuoted >actual &&
55 test_cmp expect actual
58 test_expect_success
'internal and more trailing whitespace' '
59 echo "big QQ blue" | q_to_tab >expect &&
60 git config --get section.sparseAndBiggerTail >actual &&
61 test_cmp expect actual
64 test_expect_success
'internal and more trailing whitespace, all quoted' '
65 echo "big QQ blue Q Q" | q_to_tab >expect &&
66 git config --get section.sparseAndBiggerTailQuoted >actual &&
67 test_cmp expect actual
70 test_expect_success
'internal and more trailing whitespace, not all quoted' '
71 echo "big QQ blue Q Q" | q_to_tab >expect &&
72 git config --get section.sparseAndBiggerTailQuotedPlus >actual &&
73 test_cmp expect actual
76 test_expect_success
'leading and trailing whitespace' '
77 echo "big blue" >expect &&
78 git config --get section.headAndTail >actual &&
79 test_cmp expect actual
82 test_expect_success
'leading and trailing whitespace, all quoted' '
83 echo "Qbig blue " | q_to_tab >expect &&
84 git config --get section.headAndTailQuoted >actual &&
85 test_cmp expect actual
88 test_expect_success
'leading and trailing whitespace, not all quoted' '
89 echo "Qbig blue " | q_to_tab >expect &&
90 git config --get section.headAndTailQuotedPlus >actual &&
91 test_cmp expect actual
94 test_expect_success
'inline comment' '
95 echo "big blue" >expect &&
96 git config --get section.annotated >actual &&
97 test_cmp expect actual
100 test_expect_success
'inline comment, quoted' '
101 echo "big blue" >expect &&
102 git config --get section.annotatedQuoted >actual &&
103 test_cmp expect actual
106 test_expect_success
'clear default config' '
112 penguin = little blue
114 test_expect_success
'initial' '
115 git config section.penguin "little blue" &&
116 test_cmp expect .git/config
121 penguin = little blue
124 test_expect_success
'mixed case' '
125 git config Section.Movie BadPhysics &&
126 test_cmp expect .git/config
131 penguin = little blue
136 test_expect_success
'similar section' '
137 git config Sections.WhatEver Second &&
138 test_cmp expect .git/config
143 penguin = little blue
149 test_expect_success
'uppercase section' '
150 git config SECTION.UPPERCASE true &&
151 test_cmp expect .git/config
154 test_expect_success
'replace with non-match' '
155 git config section.penguin kingpin !blue
158 test_expect_success
'replace with non-match (actually matching)' '
159 git config section.penguin "very blue" !kingpin
172 test_expect_success
'non-match result' 'test_cmp expect .git/config'
174 test_expect_success
'find mixed-case key by canonical name' '
175 test_cmp_config Second sections.whatever
178 test_expect_success
'find mixed-case key by non-canonical name' '
179 test_cmp_config Second SeCtIoNs.WhAtEvEr
182 test_expect_success
'subsections are not canonicalized by git-config' '
183 cat >>.git/config <<-\EOF &&
186 [section "SubSection"]
189 test_cmp_config one section.subsection.key &&
190 test_cmp_config two section.SubSection.key
193 test_missing_key
() {
196 test_expect_success
"value for $title is not printed" '
197 test_must_fail git config "$key" >out 2>err &&
198 test_must_be_empty out &&
199 test_must_be_empty err
203 test_missing_key
'missingsection.missingkey' 'missing section and missing key'
204 test_missing_key
'missingsection.penguin' 'missing section and existing key'
205 test_missing_key
'section.missingkey' 'existing section and missing key'
206 test_missing_key
'section.MissingSubSection.missingkey' 'missing subsection and missing key'
207 test_missing_key
'section.SubSection.missingkey' 'existing subsection and missing key'
208 test_missing_key
'section.MissingSubSection.key' 'missing subsection and existing key'
210 cat > .git
/config
<<\EOF
219 test_expect_success
'unset with cont. lines' '
220 git config --unset beta.baz
230 test_expect_success
'unset with cont. lines is correct' 'test_cmp expect .git/config'
232 cat > .git
/config
<< EOF
233 [beta] ; silly comment # another comment
234 noIndent= sillyValue ; 'nother silly comment
238 haha ="beta" # last silly comment
241 [nextSection] noNewline = ouch
244 cp .git
/config .git
/config2
246 test_expect_success
'multiple unset' '
247 git config --unset-all beta.haha
251 [beta] ; silly comment # another comment
252 noIndent= sillyValue ; 'nother silly comment
256 [nextSection] noNewline = ouch
259 test_expect_success
'multiple unset is correct' '
260 test_cmp expect .git/config
263 cp .git
/config2 .git
/config
265 test_expect_success
'--replace-all missing value' '
266 test_must_fail git config --replace-all beta.haha &&
267 test_cmp .git/config2 .git/config
272 test_expect_success
'--replace-all' '
273 git config --replace-all beta.haha gamma
277 [beta] ; silly comment # another comment
278 noIndent= sillyValue ; 'nother silly comment
283 [nextSection] noNewline = ouch
286 test_expect_success
'all replaced' '
287 test_cmp expect .git/config
291 [beta] ; silly comment # another comment
292 noIndent= sillyValue ; 'nother silly comment
297 [nextSection] noNewline = ouch
299 test_expect_success
'really mean test' '
300 git config beta.haha alpha &&
301 test_cmp expect .git/config
305 [beta] ; silly comment # another comment
306 noIndent= sillyValue ; 'nother silly comment
314 test_expect_success
'really really mean test' '
315 git config nextsection.nonewline wow &&
316 test_cmp expect .git/config
319 test_expect_success
'get value' '
320 test_cmp_config alpha beta.haha
324 [beta] ; silly comment # another comment
325 noIndent= sillyValue ; 'nother silly comment
332 test_expect_success
'unset' '
333 git config --unset beta.haha &&
334 test_cmp expect .git/config
338 [beta] ; silly comment # another comment
339 noIndent= sillyValue ; 'nother silly comment
345 NoNewLine = wow2 for me
347 test_expect_success
'multivar' '
348 git config nextsection.NoNewLine "wow2 for me" "for me$" &&
349 test_cmp expect .git/config
352 test_expect_success
'non-match' '
353 git config --get nextsection.nonewline !for
356 test_expect_success
'non-match value' '
357 test_cmp_config wow --get nextsection.nonewline !for
360 test_expect_success
'multi-valued get returns final one' '
361 test_cmp_config "wow2 for me" --get nextsection.nonewline
364 test_expect_success
'multi-valued get-all returns all' '
365 cat >expect <<-\EOF &&
369 git config --get-all nextsection.nonewline >actual &&
370 test_cmp expect actual
374 [beta] ; silly comment # another comment
375 noIndent= sillyValue ; 'nother silly comment
381 NoNewLine = wow2 for me
383 test_expect_success
'multivar replace' '
384 git config nextsection.nonewline "wow3" "wow$" &&
385 test_cmp expect .git/config
388 test_expect_success
'ambiguous unset' '
389 test_must_fail git config --unset nextsection.nonewline
392 test_expect_success
'invalid unset' '
393 test_must_fail git config --unset somesection.nonewline
397 [beta] ; silly comment # another comment
398 noIndent= sillyValue ; 'nother silly comment
403 NoNewLine = wow2 for me
406 test_expect_success
'multivar unset' '
407 git config --unset nextsection.nonewline "wow3$" &&
408 test_cmp expect .git/config
411 test_expect_success
'invalid key' 'test_must_fail git config inval.2key blabla'
413 test_expect_success
'correct key' 'git config 123456.a123 987'
415 test_expect_success
'hierarchical section' '
416 git config Version.1.2.3eX.Alpha beta
420 [beta] ; silly comment # another comment
421 noIndent= sillyValue ; 'nother silly comment
426 NoNewLine = wow2 for me
433 test_expect_success
'hierarchical section value' '
434 test_cmp expect .git/config
438 beta.noindent=sillyValue
439 nextsection.nonewline=wow2 for me
441 version.1.2.3eX.alpha=beta
444 test_expect_success
'working --list' '
445 git config --list > output &&
446 test_cmp expect output
448 test_expect_success
'--list without repo produces empty output' '
449 git --git-dir=nonexistent config --list >output &&
450 test_must_be_empty output
455 nextsection.nonewline
457 version.1.2.3eX.alpha
460 test_expect_success
'--name-only --list' '
461 git config --name-only --list >output &&
462 test_cmp expect output
466 beta.noindent sillyValue
467 nextsection.nonewline wow2 for me
470 test_expect_success
'--get-regexp' '
471 git config --get-regexp in >output &&
472 test_cmp expect output
477 nextsection.nonewline
480 test_expect_success
'--name-only --get-regexp' '
481 git config --name-only --get-regexp in >output &&
482 test_cmp expect output
490 test_expect_success
'--add' '
491 git config --add nextsection.nonewline "wow4 for you" &&
492 git config --get-all nextsection.nonewline > output &&
493 test_cmp expect output
496 cat > .git
/config
<< EOF
503 test_expect_success
'get variable with no value' '
504 git config --get novalue.variable ^$
507 test_expect_success
'get variable with empty value' '
508 git config --get emptyvalue.variable ^$
511 echo novalue.variable
> expect
513 test_expect_success
'get-regexp variable with no value' '
514 git config --get-regexp novalue > output &&
515 test_cmp expect output
518 echo 'novalue.variable true' > expect
520 test_expect_success
'get-regexp --bool variable with no value' '
521 git config --bool --get-regexp novalue > output &&
522 test_cmp expect output
525 echo 'emptyvalue.variable ' > expect
527 test_expect_success
'get-regexp variable with empty value' '
528 git config --get-regexp emptyvalue > output &&
529 test_cmp expect output
534 test_expect_success
'get bool variable with no value' '
535 git config --bool novalue.variable > output &&
536 test_cmp expect output
541 test_expect_success
'get bool variable with empty value' '
542 git config --bool emptyvalue.variable > output &&
543 test_cmp expect output
546 test_expect_success
'no arguments, but no crash' '
547 test_must_fail git config >output 2>&1 &&
548 test_grep usage output
551 cat > .git
/config
<< EOF
563 test_expect_success
'new section is partial match of another' '
565 test_cmp expect .git/config
578 test_expect_success
'new variable inserts into proper section' '
581 test_cmp expect .git/config
584 test_expect_success
'alternative --file (non-existing file should fail)' '
585 test_must_fail git config --file non-existing-config -l &&
586 test_must_fail git config --file non-existing-config test.xyzzy
589 cat > other-config
<< EOF
598 test_expect_success
'alternative GIT_CONFIG' '
599 GIT_CONFIG=other-config git config --list >output &&
600 test_cmp expect output
603 test_expect_success
'alternative GIT_CONFIG (--file)' '
604 git config --file other-config --list >output &&
605 test_cmp expect output
608 test_expect_success
'alternative GIT_CONFIG (--file=-)' '
609 git config --file - --list <other-config >output &&
610 test_cmp expect output
613 test_expect_success
'setting a value in stdin is an error' '
614 test_must_fail git config --file - some.value foo
617 test_expect_success
'editing stdin is an error' '
618 test_must_fail git config --file - --edit
621 test_expect_success
'refer config from subdirectory' '
623 test_cmp_config -C x strasse --file=../other-config --get ein.bahn
633 test_expect_success
'--set in alternative file' '
634 git config --file=other-config anwohner.park ausweis &&
635 test_cmp expect other-config
638 cat > .git
/config
<< EOF
645 [branch "1 234 blabl/a"]
649 test_expect_success
'rename section' '
650 git config --rename-section branch.eins branch.zwei
660 [branch "1 234 blabl/a"]
664 test_expect_success
'rename succeeded' '
665 test_cmp expect .git/config
668 test_expect_success
'rename non-existing section' '
669 test_must_fail git config --rename-section \
670 branch."world domination" branch.drei
673 test_expect_success
'rename succeeded' '
674 test_cmp expect .git/config
677 test_expect_success
'rename another section' '
678 git config --rename-section branch."1 234 blabl/a" branch.drei
692 test_expect_success
'rename succeeded' '
693 test_cmp expect .git/config
696 cat >> .git
/config
<< EOF
697 [branch "vier"] z = 1
700 test_expect_success
'rename a section with a var on the same line' '
701 git config --rename-section branch.vier branch.zwei
717 test_expect_success
'rename succeeded' '
718 test_cmp expect .git/config
721 test_expect_success
'renaming empty section name is rejected' '
722 test_must_fail git config --rename-section branch.zwei ""
725 test_expect_success
'renaming to bogus section is rejected' '
726 test_must_fail git config --rename-section branch.zwei "bogus name"
729 test_expect_success
'renaming a section with a long line' '
732 printf " c = d %1024s [a] e = f\\n" " " &&
733 printf "[a] g = h\\n"
735 git config -f y --rename-section a xyz &&
736 test_must_fail git config -f y b.e
739 test_expect_success
'renaming an embedded section with a long line' '
742 printf " c = d %1024s [a] [foo] e = f\\n" " " &&
743 printf "[a] g = h\\n"
745 git config -f y --rename-section a xyz &&
746 test_must_fail git config -f y foo.e
749 test_expect_success
'renaming a section with an overly-long line' '
752 printf " c = d %525000s e" " " &&
753 printf "[a] g = h\\n"
755 test_must_fail git config -f y --rename-section a xyz 2>err &&
756 grep "refusing to work with overly long line in .y. on line 2" err
759 cat >> .git
/config
<< EOF
760 [branch "zwei"] a = 1 [branch "vier"]
763 test_expect_success
'remove section' '
764 git config --remove-section branch.zwei
774 test_expect_success
'section was removed properly' '
775 test_cmp expect .git/config
781 dbname = %Ggitcvs2.%a.%m.sqlite
783 dbname = %Ggitcvs1.%a.%m.sqlite
786 test_expect_success
'section ending' '
788 git config gitcvs.enabled true &&
789 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
790 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
791 test_cmp expect .git/config
795 test_expect_success numbers
'
796 git config kilo.gram 1k &&
797 git config mega.ton 1m &&
799 echo 1048576 >>expect &&
800 git config --int --get kilo.gram >actual &&
801 git config --int --get mega.ton >>actual &&
802 test_cmp expect actual
805 test_expect_success
'--int is at least 64 bits' '
806 git config giga.watts 121g &&
808 test_cmp_config 129922760704 --int --get giga.watts
811 test_expect_success
'invalid unit' '
812 git config aninvalid.unit "1auto" &&
813 test_cmp_config 1auto aninvalid.unit &&
814 test_must_fail git config --int --get aninvalid.unit 2>actual &&
815 test_grep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
818 test_expect_success
'invalid unit boolean' '
819 git config commit.gpgsign "1true" &&
820 test_cmp_config 1true commit.gpgsign &&
821 test_must_fail git config --bool --get commit.gpgsign 2>actual &&
822 test_grep "bad boolean config value .1true. for .commit.gpgsign." actual
825 test_expect_success
'line number is reported correctly' '
826 printf "[bool]\n\tvar\n" >invalid &&
827 test_must_fail git config -f invalid --path bool.var 2>actual &&
828 test_grep "line 2" actual
831 test_expect_success
'invalid stdin config' '
832 echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
833 test_grep "bad config line 1 in standard input" output
847 test_expect_success bool
'
849 git config bool.true1 01 &&
850 git config bool.true2 -1 &&
851 git config bool.true3 YeS &&
852 git config bool.true4 true &&
853 git config bool.false1 000 &&
854 git config bool.false2 "" &&
855 git config bool.false3 nO &&
856 git config bool.false4 FALSE &&
860 git config --bool --get bool.true$i >>result &&
861 git config --bool --get bool.false$i >>result || return 1
863 test_cmp expect result'
865 test_expect_success
'invalid bool (--get)' '
867 git config bool.nobool foobar &&
868 test_must_fail git config --bool --get bool.nobool'
870 test_expect_success
'invalid bool (set)' '
872 test_must_fail git config --bool bool.nobool foobar'
886 test_expect_success
'set --bool' '
889 git config --bool bool.true1 01 &&
890 git config --bool bool.true2 -1 &&
891 git config --bool bool.true3 YeS &&
892 git config --bool bool.true4 true &&
893 git config --bool bool.false1 000 &&
894 git config --bool bool.false2 "" &&
895 git config --bool bool.false3 nO &&
896 git config --bool bool.false4 FALSE &&
897 test_cmp expect .git/config'
906 test_expect_success
'set --int' '
909 git config --int int.val1 01 &&
910 git config --int int.val2 -1 &&
911 git config --int int.val3 5m &&
912 test_cmp expect .git/config
915 test_expect_success
'get --bool-or-int' '
916 cat >.git/config <<-\EOF &&
926 cat >expect <<-\EOF &&
935 git config --bool-or-int bool.true1 &&
936 git config --bool-or-int bool.true2 &&
937 git config --bool-or-int bool.false &&
938 git config --bool-or-int int.int1 &&
939 git config --bool-or-int int.int2 &&
940 git config --bool-or-int int.int3
942 test_cmp expect actual
957 test_expect_success
'set --bool-or-int' '
959 git config --bool-or-int bool.true1 true &&
960 git config --bool-or-int bool.false1 false &&
961 git config --bool-or-int bool.true2 yes &&
962 git config --bool-or-int bool.false2 no &&
963 git config --bool-or-int int.int1 0 &&
964 git config --bool-or-int int.int2 1 &&
965 git config --bool-or-int int.int3 -1 &&
966 test_cmp expect .git/config
976 test_expect_success
!MINGW
'set --path' '
978 git config --path path.home "~/" &&
979 git config --path path.normal "/dev/null" &&
980 git config --path path.trailingtilde "foo~" &&
981 test_cmp expect .git/config'
983 if test_have_prereq
!MINGW
&& test "${HOME+set}"
985 test_set_prereq HOMEVAR
994 test_expect_success HOMEVAR
'get --path' '
995 git config --get --path path.home > result &&
996 git config --get --path path.normal >> result &&
997 git config --get --path path.trailingtilde >> result &&
998 test_cmp expect result
1006 test_expect_success
!MINGW
'get --path copes with unset $HOME' '
1009 test_must_fail git config --get --path path.home \
1011 git config --get --path path.normal >>result &&
1012 git config --get --path path.trailingtilde >>result
1014 test_grep "[Ff]ailed to expand.*~/" msg &&
1015 test_cmp expect result
1018 test_expect_success
'get --path barfs on boolean variable' '
1019 echo "[path]bool" >.git/config &&
1020 test_must_fail git config --get --path path.bool
1023 test_expect_success
'get --expiry-date' '
1024 rel="3.weeks.5.days.00:00" &&
1025 rel_out="$rel ->" &&
1026 cat >.git/config <<-\EOF &&
1028 valid1 = "3.weeks.5.days 00:00"
1029 valid2 = "Fri Jun 4 15:46:55 2010"
1030 valid3 = "2017/11/11 11:11:11PM"
1031 valid4 = "2017/11/10 09:08:07 PM"
1035 cat >expect <<-EOF &&
1036 $(test-tool date timestamp $rel)
1042 : "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
1044 echo "$rel_out $(git config --expiry-date date.valid1)" &&
1045 git config --expiry-date date.valid2 &&
1046 git config --expiry-date date.valid3 &&
1047 git config --expiry-date date.valid4 &&
1048 git config --expiry-date date.valid5
1050 test_cmp expect actual &&
1051 test_must_fail git config --expiry-date date.invalid1
1054 test_expect_success
'get --type=color' '
1056 git config foo.color "red" &&
1057 git config --get --type=color foo.color >actual.raw &&
1058 test_decode_color <actual.raw >actual &&
1059 echo "<RED>" >expect &&
1060 test_cmp expect actual
1068 test_expect_success
'set --type=color' '
1070 git config --type=color foo.color "red" &&
1071 test_cmp expect .git/config
1074 test_expect_success
'get --type=color barfs on non-color' '
1075 echo "[foo]bar=not-a-color" >.git/config &&
1076 test_must_fail git config --get --type=color foo.bar
1079 test_expect_success
'set --type=color barfs on non-color' '
1080 test_must_fail git config --type=color foo.color "not-a-color" 2>error &&
1081 test_grep "cannot parse color" error
1088 semicolon = "test;test"
1091 test_expect_success
'quoting' '
1092 rm -f .git/config &&
1093 git config quote.leading " test" &&
1094 git config quote.ending "test " &&
1095 git config quote.semicolon "test;test" &&
1096 git config quote.hash "test#test" &&
1097 test_cmp expect .git/config
1100 test_expect_success
'key with newline' '
1101 test_must_fail git config "key.with
1104 test_expect_success
'value with newline' 'git config key.sub value.with\\\
1107 cat > .git
/config
<<\EOF
1112 noncont
= not continued
; \
1118 section.continued
=continued
1119 section.noncont
=not continued
1120 section.quotecont
=cont
;inued
1123 test_expect_success
'value continued on next line' '
1124 git config --list > result &&
1125 test_cmp expect result
1128 cat > .git
/config
<<\EOF
1129 [section
"sub=section"]
1138 section.sub
=section.val1
1139 foo
=barQsection.sub
=section.val2
1141 barQsection.sub
=section.val3
1144 Qsection.sub
=section.val4
1145 Qsection.sub
=section.val5Q
1147 test_expect_success
'--null --list' '
1148 git config --null --list >result.raw &&
1149 nul_to_q <result.raw >result &&
1151 test_cmp expect result
1154 test_expect_success
'--null --get-regexp' '
1155 git config --null --get-regexp "val[0-9]" >result.raw &&
1156 nul_to_q <result.raw >result &&
1158 test_cmp expect result
1161 test_expect_success
'inner whitespace kept verbatim, spaces only' '
1162 echo "foo bar" >expect &&
1163 git config section.val "foo bar" &&
1164 git config --get section.val >actual &&
1165 test_cmp expect actual
1168 test_expect_success
'inner whitespace kept verbatim, horizontal tabs only' '
1169 echo "fooQQbar" | q_to_tab >expect &&
1170 git config section.val "$(cat expect)" &&
1171 git config --get section.val >actual &&
1172 test_cmp expect actual
1175 test_expect_success
'inner whitespace kept verbatim, horizontal tabs and spaces' '
1176 echo "foo Q bar" | q_to_tab >expect &&
1177 git config section.val "$(cat expect)" &&
1178 git config --get section.val >actual &&
1179 test_cmp expect actual
1182 test_expect_success SYMLINKS
'symlinked configuration' '
1183 ln -s notyet myconfig &&
1184 git config --file=myconfig test.frotz nitfol &&
1187 test "z$(git config --file=notyet test.frotz)" = znitfol &&
1188 git config --file=myconfig test.xyzzy rezrov &&
1191 cat >expect <<-\EOF &&
1196 git config --file=notyet test.frotz &&
1197 git config --file=notyet test.xyzzy
1199 test_cmp expect actual
1202 test_expect_success SYMLINKS
'symlink to nonexistent configuration' '
1203 ln -s doesnotexist linktonada &&
1204 ln -s linktonada linktolinktonada &&
1205 test_must_fail git config --file=linktonada --list &&
1206 test_must_fail git config --file=linktolinktonada --list
1209 test_expect_success
'check split_cmdline return' '
1210 test_when_finished "rm -rf repo" &&
1214 git config alias.split-cmdline-fix "echo \"" &&
1215 test_must_fail git split-cmdline-fix &&
1218 git commit -m "initial commit" &&
1219 git config branch.main.mergeoptions "echo \"" &&
1220 test_must_fail git merge main
1224 test_expect_success
'git -c "key=value" support' '
1225 cat >expect <<-\EOF &&
1231 git -c section.name=value config section.name &&
1232 git -c foo.CamelCase=value config foo.camelcase &&
1233 git -c foo.flag config --bool foo.flag
1235 test_cmp expect actual &&
1236 test_must_fail git -c name=value config section.name
1239 # We just need a type-specifier here that cares about the
1240 # distinction internally between a NULL boolean and a real
1241 # string (because most of git's internal parsers do care).
1242 # Using "--path" works, but we do not otherwise care about
1244 test_expect_success
'git -c can represent empty string' '
1246 git -c foo.empty= config --path foo.empty >actual &&
1247 test_cmp expect actual
1250 test_expect_success
'key sanity-checking' '
1251 test_must_fail git config foo=bar &&
1252 test_must_fail git config foo=.bar &&
1253 test_must_fail git config foo.ba=r &&
1254 test_must_fail git config foo.1bar &&
1255 test_must_fail git config foo."ba
1257 test_must_fail git config . false &&
1258 test_must_fail git config .foo false &&
1259 test_must_fail git config foo. false &&
1260 test_must_fail git config .foo. false &&
1261 git config foo.bar true &&
1262 git config foo."ba =z".bar false
1265 test_expect_success
'git -c works with aliases of builtins' '
1266 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
1268 git checkconfig >actual &&
1269 test_cmp expect actual
1272 test_expect_success
'aliases can be CamelCased' '
1273 test_when_finished "rm -rf repo" &&
1278 git config alias.CamelCased "rev-parse HEAD" &&
1279 git CamelCased >out &&
1280 git rev-parse HEAD >expect &&
1285 test_expect_success
'git -c does not split values on equals' '
1286 echo "value with = in it" >expect &&
1287 git -c section.foo="value with = in it" config section.foo >actual &&
1288 test_cmp expect actual
1291 test_expect_success
'git -c dies on bogus config' '
1292 test_must_fail git -c core.bare=foo rev-parse
1295 test_expect_success
'git -c complains about empty key' '
1296 test_must_fail git -c "=foo" rev-parse
1299 test_expect_success
'git -c complains about empty key and value' '
1300 test_must_fail git -c "" rev-parse
1303 test_expect_success
'multiple git -c appends config' '
1304 test_config alias.x "!git -c x.two=2 config --get-regexp ^x\.*" &&
1305 cat >expect <<-\EOF &&
1309 git -c x.one=1 x >actual &&
1310 test_cmp expect actual
1313 test_expect_success
'last one wins: two level vars' '
1315 # sec.var and sec.VAR are the same variable, as the first
1316 # and the last level of a configuration variable name is
1321 git -c sec.var=val -c sec.VAR=VAL config --get sec.var >actual &&
1322 test_cmp expect actual &&
1323 git -c SEC.var=val -c sec.var=VAL config --get sec.var >actual &&
1324 test_cmp expect actual &&
1326 git -c sec.var=val -c sec.VAR=VAL config --get SEC.var >actual &&
1327 test_cmp expect actual &&
1328 git -c SEC.var=val -c sec.var=VAL config --get sec.VAR >actual &&
1329 test_cmp expect actual
1332 test_expect_success
'last one wins: three level vars' '
1334 # v.a.r and v.A.r are not the same variable, as the middle
1335 # level of a three-level configuration variable name is
1339 git -c v.a.r=val -c v.A.r=VAL config --get v.a.r >actual &&
1340 test_cmp expect actual &&
1341 git -c v.a.r=val -c v.A.r=VAL config --get V.a.R >actual &&
1342 test_cmp expect actual &&
1344 # v.a.r and V.a.R are the same variable, as the first
1345 # and the last level of a configuration variable name is
1349 git -c v.a.r=val -c v.a.R=VAL config --get v.a.r >actual &&
1350 test_cmp expect actual &&
1351 git -c v.a.r=val -c V.a.r=VAL config --get v.a.r >actual &&
1352 test_cmp expect actual &&
1353 git -c v.a.r=val -c v.a.R=VAL config --get V.a.R >actual &&
1354 test_cmp expect actual &&
1355 git -c v.a.r=val -c V.a.r=VAL config --get V.a.R >actual &&
1356 test_cmp expect actual
1359 test_expect_success
'old-fashioned settings are case insensitive' '
1360 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1362 cat >testConfig_actual <<-EOF &&
1366 q_to_tab >testConfig_expect <<-EOF &&
1370 git config -f testConfig_actual "v.a.r" value2 &&
1371 test_cmp testConfig_expect testConfig_actual &&
1373 cat >testConfig_actual <<-EOF &&
1377 q_to_tab >testConfig_expect <<-EOF &&
1381 git config -f testConfig_actual "V.a.R" value2 &&
1382 test_cmp testConfig_expect testConfig_actual &&
1384 cat >testConfig_actual <<-EOF &&
1388 q_to_tab >testConfig_expect <<-EOF &&
1393 git config -f testConfig_actual "V.A.r" value2 &&
1394 test_cmp testConfig_expect testConfig_actual &&
1396 cat >testConfig_actual <<-EOF &&
1400 q_to_tab >testConfig_expect <<-EOF &&
1405 git config -f testConfig_actual "v.A.r" value2 &&
1406 test_cmp testConfig_expect testConfig_actual
1409 test_expect_success
'setting different case sensitive subsections ' '
1410 test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1412 cat >testConfig_actual <<-EOF &&
1422 q_to_tab >testConfig_expect <<-EOF &&
1435 git config -f testConfig_actual a.b.c v2 &&
1436 # match section and subsection, key is cased differently.
1437 git config -f testConfig_actual K.E.y v2 &&
1438 # section and key are matched case insensitive, but subsection needs
1439 # to match; When writing out new values only the key is adjusted
1440 git config -f testConfig_actual v.A.r v2 &&
1441 # subsection is not matched:
1442 git config -f testConfig_actual d.E.f v2 &&
1443 test_cmp testConfig_expect testConfig_actual
1446 for VAR
in a .a a. a
.0b a.
"b c". a.
"b c".0d
1448 test_expect_success
"git -c $VAR=VAL rejects invalid '$VAR'" '
1449 test_must_fail git -c "$VAR=VAL" config -l
1453 for VAR
in a.b a.
"b c".d
1455 test_expect_success
"git -c $VAR=VAL works with valid '$VAR'" '
1457 git -c "$VAR=VAL" config --get "$VAR" >actual &&
1458 test_cmp expect actual
1462 test_expect_success
'git -c is not confused by empty environment' '
1463 GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
1466 test_expect_success
'GIT_CONFIG_PARAMETERS handles old-style entries' '
1467 v="${SQ}key.one=foo${SQ}" &&
1468 v="$v ${SQ}key.two=bar${SQ}" &&
1469 v="$v ${SQ}key.ambiguous=section.whatever=value${SQ}" &&
1470 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1471 cat >expect <<-EOF &&
1474 key.ambiguous section.whatever=value
1476 test_cmp expect actual
1479 test_expect_success
'GIT_CONFIG_PARAMETERS handles new-style entries' '
1480 v="${SQ}key.one${SQ}=${SQ}foo${SQ}" &&
1481 v="$v ${SQ}key.two${SQ}=${SQ}bar${SQ}" &&
1482 v="$v ${SQ}key.ambiguous=section.whatever${SQ}=${SQ}value${SQ}" &&
1483 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1484 cat >expect <<-EOF &&
1487 key.ambiguous=section.whatever value
1489 test_cmp expect actual
1492 test_expect_success
'old and new-style entries can mix' '
1493 v="${SQ}key.oldone=oldfoo${SQ}" &&
1494 v="$v ${SQ}key.newone${SQ}=${SQ}newfoo${SQ}" &&
1495 v="$v ${SQ}key.oldtwo=oldbar${SQ}" &&
1496 v="$v ${SQ}key.newtwo${SQ}=${SQ}newbar${SQ}" &&
1497 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1498 cat >expect <<-EOF &&
1504 test_cmp expect actual
1507 test_expect_success
'old and new bools with ambiguous subsection' '
1508 v="${SQ}key.with=equals.oldbool${SQ}" &&
1509 v="$v ${SQ}key.with=equals.newbool${SQ}=" &&
1510 GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
1511 cat >expect <<-EOF &&
1512 key.with equals.oldbool
1513 key.with=equals.newbool
1515 test_cmp expect actual
1518 test_expect_success
'detect bogus GIT_CONFIG_PARAMETERS' '
1519 cat >expect <<-\EOF &&
1523 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ} ${SQ}env.two=two${SQ}" \
1524 git config --get-regexp "env.*" >actual &&
1525 test_cmp expect actual &&
1527 cat >expect <<-EOF &&
1531 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ$SQ$SQ ${SQ}env.two=two${SQ}" \
1532 git config --get-regexp "env.*" >actual &&
1533 test_cmp expect actual &&
1535 test_must_fail env \
1536 GIT_CONFIG_PARAMETERS="${SQ}env.one=one${SQ}\\$SQ ${SQ}env.two=two${SQ}" \
1537 git config --get-regexp "env.*"
1540 test_expect_success
'git --config-env=key=envvar support' '
1541 cat >expect <<-\EOF &&
1550 ENVVAR=value git --config-env=core.name=ENVVAR config core.name &&
1551 ENVVAR=value git --config-env core.name=ENVVAR config core.name &&
1552 ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase &&
1553 ENVVAR=value git --config-env foo.CamelCase=ENVVAR config foo.camelcase &&
1554 ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag &&
1555 ENVVAR= git --config-env foo.flag=ENVVAR config --bool foo.flag
1557 test_cmp expect actual
1560 test_expect_success
'git --config-env with missing value' '
1561 test_must_fail env ENVVAR=value git --config-env 2>error &&
1562 grep "no config key given for --config-env" error &&
1563 test_must_fail env ENVVAR=value git --config-env config core.name 2>error &&
1564 grep "invalid config format: config" error
1567 test_expect_success
'git --config-env fails with invalid parameters' '
1568 test_must_fail git --config-env=foo.flag config --bool foo.flag 2>error &&
1569 test_grep "invalid config format: foo.flag" error &&
1570 test_must_fail git --config-env=foo.flag= config --bool foo.flag 2>error &&
1571 test_grep "missing environment variable name for configuration ${SQ}foo.flag${SQ}" error &&
1572 sane_unset NONEXISTENT &&
1573 test_must_fail git --config-env=foo.flag=NONEXISTENT config --bool foo.flag 2>error &&
1574 test_grep "missing environment variable ${SQ}NONEXISTENT${SQ} for configuration ${SQ}foo.flag${SQ}" error
1577 test_expect_success
'git -c and --config-env work together' '
1578 cat >expect <<-\EOF &&
1582 ENVVAR=env-value git \
1583 -c bar.cmd=cmd-value \
1584 --config-env=bar.env=ENVVAR \
1585 config --get-regexp "^bar.*" >actual &&
1586 test_cmp expect actual
1589 test_expect_success
'git -c and --config-env override each other' '
1590 cat >expect <<-\EOF &&
1595 ENVVAR=env git -c bar.bar=cmd --config-env=bar.bar=ENVVAR config bar.bar &&
1596 ENVVAR=env git --config-env=bar.bar=ENVVAR -c bar.bar=cmd config bar.bar
1598 test_cmp expect actual
1601 test_expect_success
'--config-env handles keys with equals' '
1602 echo value=with=equals >expect &&
1603 ENVVAR=value=with=equals git \
1604 --config-env=section.subsection=with=equals.key=ENVVAR \
1605 config section.subsection=with=equals.key >actual &&
1606 test_cmp expect actual
1609 test_expect_success
'git config handles environment config pairs' '
1610 GIT_CONFIG_COUNT=2 \
1611 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="foo" \
1612 GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="bar" \
1613 git config --get-regexp "pair.*" >actual &&
1614 cat >expect <<-EOF &&
1618 test_cmp expect actual
1621 test_expect_success
'git config ignores pairs without count' '
1622 test_must_fail env GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1623 git config pair.one 2>error &&
1624 test_must_be_empty error
1627 test_expect_success
'git config ignores pairs exceeding count' '
1628 GIT_CONFIG_COUNT=1 \
1629 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1630 GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
1631 git config --get-regexp "pair.*" >actual 2>error &&
1632 cat >expect <<-EOF &&
1635 test_cmp expect actual &&
1636 test_must_be_empty error
1639 test_expect_success
'git config ignores pairs with zero count' '
1640 test_must_fail env \
1641 GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1642 git config pair.one 2>error &&
1643 test_must_be_empty error
1646 test_expect_success
'git config ignores pairs with empty count' '
1647 test_must_fail env \
1648 GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1649 git config pair.one 2>error &&
1650 test_must_be_empty error
1653 test_expect_success
'git config fails with invalid count' '
1654 test_must_fail env GIT_CONFIG_COUNT=10a git config --list 2>error &&
1655 test_grep "bogus count" error &&
1656 test_must_fail env GIT_CONFIG_COUNT=9999999999999999 git config --list 2>error &&
1657 test_grep "too many entries" error
1660 test_expect_success
'git config fails with missing config key' '
1661 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_VALUE_0="value" \
1662 git config --list 2>error &&
1663 test_grep "missing config key" error
1666 test_expect_success
'git config fails with missing config value' '
1667 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="pair.one" \
1668 git config --list 2>error &&
1669 test_grep "missing config value" error
1672 test_expect_success
'git config fails with invalid config pair key' '
1673 test_must_fail env GIT_CONFIG_COUNT=1 \
1674 GIT_CONFIG_KEY_0= GIT_CONFIG_VALUE_0=value \
1675 git config --list &&
1676 test_must_fail env GIT_CONFIG_COUNT=1 \
1677 GIT_CONFIG_KEY_0=missing-section GIT_CONFIG_VALUE_0=value \
1681 test_expect_success
'environment overrides config file' '
1682 test_when_finished "rm -f .git/config" &&
1683 cat >.git/config <<-EOF &&
1687 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=override \
1688 git config pair.one >actual &&
1689 cat >expect <<-EOF &&
1692 test_cmp expect actual
1695 test_expect_success
'GIT_CONFIG_PARAMETERS overrides environment config' '
1696 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \
1697 GIT_CONFIG_PARAMETERS="${SQ}pair.one=override${SQ}" \
1698 git config pair.one >actual &&
1699 cat >expect <<-EOF &&
1702 test_cmp expect actual
1705 test_expect_success
'command line overrides environment config' '
1706 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=pair.one GIT_CONFIG_VALUE_0=value \
1707 git -c pair.one=override config pair.one >actual &&
1708 cat >expect <<-EOF &&
1711 test_cmp expect actual
1714 test_expect_success
'git config --edit works' '
1715 git config -f tmp test.value no &&
1716 echo test.value=yes >expect &&
1717 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1718 git config -f tmp --list >actual &&
1719 test_cmp expect actual
1722 test_expect_success
'git config --edit respects core.editor' '
1723 git config -f tmp test.value no &&
1724 echo test.value=yes >expect &&
1725 test_config core.editor "echo [test]value=yes >" &&
1726 git config -f tmp --edit &&
1727 git config -f tmp --list >actual &&
1728 test_cmp expect actual
1731 # malformed configuration files
1732 test_expect_success
'barf on syntax error' '
1733 cat >.git/config <<-\EOF &&
1738 test_must_fail git config --get section.key 2>error &&
1739 test_grep " line 3 " error
1742 test_expect_success
'barf on incomplete section header' '
1743 cat >.git/config <<-\EOF &&
1744 # broken section line
1748 test_must_fail git config --get section.key 2>error &&
1749 test_grep " line 2 " error
1752 test_expect_success
'barf on incomplete string' '
1753 cat >.git/config <<-\EOF &&
1754 # broken value string
1758 test_must_fail git config --get section.key 2>error &&
1759 test_grep " line 3 " error
1762 test_expect_success
'urlmatch' '
1763 cat >.git/config <<-\EOF &&
1766 [http "https://weak.example.com"]
1768 cookieFile = /tmp/cookie.txt
1771 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1772 test_must_be_empty actual &&
1774 echo true >expect &&
1775 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
1776 test_cmp expect actual &&
1778 echo false >expect &&
1779 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual &&
1780 test_cmp expect actual &&
1783 echo http.cookiefile /tmp/cookie.txt &&
1784 echo http.sslverify false
1786 git config --get-urlmatch HTTP https://weak.example.com >actual &&
1787 test_cmp expect actual
1790 test_expect_success
'urlmatch with --show-scope' '
1791 cat >.git/config <<-\EOF &&
1792 [http "https://weak.example.com"]
1794 cookieFile = /tmp/cookie.txt
1797 cat >expect <<-EOF &&
1798 local http.cookiefile /tmp/cookie.txt
1799 local http.sslverify false
1801 git config --get-urlmatch --show-scope HTTP https://weak.example.com >actual &&
1802 test_cmp expect actual
1805 test_expect_success
'urlmatch favors more specific URLs' '
1806 cat >.git/config <<-\EOF &&
1807 [http "https://example.com/"]
1808 cookieFile = /tmp/root.txt
1809 [http "https://example.com/subdirectory"]
1810 cookieFile = /tmp/subdirectory.txt
1811 [http "https://user@example.com/"]
1812 cookieFile = /tmp/user.txt
1813 [http "https://averylonguser@example.com/"]
1814 cookieFile = /tmp/averylonguser.txt
1815 [http "https://preceding.example.com"]
1816 cookieFile = /tmp/preceding.txt
1817 [http "https://*.example.com"]
1818 cookieFile = /tmp/wildcard.txt
1819 [http "https://*.example.com/wildcardwithsubdomain"]
1820 cookieFile = /tmp/wildcardwithsubdomain.txt
1821 [http "https://*.example.*"]
1822 cookieFile = /tmp/multiwildcard.txt
1823 [http "https://trailing.example.com"]
1824 cookieFile = /tmp/trailing.txt
1825 [http "https://user@*.example.com/"]
1826 cookieFile = /tmp/wildcardwithuser.txt
1827 [http "https://sub.example.com/"]
1828 cookieFile = /tmp/sub.txt
1831 echo http.cookiefile /tmp/root.txt >expect &&
1832 git config --get-urlmatch HTTP https://example.com >actual &&
1833 test_cmp expect actual &&
1835 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1836 git config --get-urlmatch HTTP https://example.com/subdirectory >actual &&
1837 test_cmp expect actual &&
1839 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1840 git config --get-urlmatch HTTP https://example.com/subdirectory/nested >actual &&
1841 test_cmp expect actual &&
1843 echo http.cookiefile /tmp/user.txt >expect &&
1844 git config --get-urlmatch HTTP https://user@example.com/ >actual &&
1845 test_cmp expect actual &&
1847 echo http.cookiefile /tmp/subdirectory.txt >expect &&
1848 git config --get-urlmatch HTTP https://averylonguser@example.com/subdirectory >actual &&
1849 test_cmp expect actual &&
1851 echo http.cookiefile /tmp/preceding.txt >expect &&
1852 git config --get-urlmatch HTTP https://preceding.example.com >actual &&
1853 test_cmp expect actual &&
1855 echo http.cookiefile /tmp/wildcard.txt >expect &&
1856 git config --get-urlmatch HTTP https://wildcard.example.com >actual &&
1857 test_cmp expect actual &&
1859 echo http.cookiefile /tmp/sub.txt >expect &&
1860 git config --get-urlmatch HTTP https://sub.example.com/wildcardwithsubdomain >actual &&
1861 test_cmp expect actual &&
1863 echo http.cookiefile /tmp/trailing.txt >expect &&
1864 git config --get-urlmatch HTTP https://trailing.example.com >actual &&
1865 test_cmp expect actual &&
1867 echo http.cookiefile /tmp/sub.txt >expect &&
1868 git config --get-urlmatch HTTP https://user@sub.example.com >actual &&
1869 test_cmp expect actual &&
1871 echo http.cookiefile /tmp/multiwildcard.txt >expect &&
1872 git config --get-urlmatch HTTP https://wildcard.example.org >actual &&
1873 test_cmp expect actual
1876 test_expect_success
'urlmatch with wildcard' '
1877 cat >.git/config <<-\EOF &&
1880 [http "https://*.example.com"]
1882 cookieFile = /tmp/cookie.txt
1885 test_expect_code 1 git config --bool --get-urlmatch doesnt.exist https://good.example.com >actual &&
1886 test_must_be_empty actual &&
1888 echo true >expect &&
1889 git config --bool --get-urlmatch http.SSLverify https://example.com >actual &&
1890 test_cmp expect actual &&
1892 echo true >expect &&
1893 git config --bool --get-urlmatch http.SSLverify https://good-example.com >actual &&
1894 test_cmp expect actual &&
1896 echo true >expect &&
1897 git config --bool --get-urlmatch http.sslverify https://deep.nested.example.com >actual &&
1898 test_cmp expect actual &&
1900 echo false >expect &&
1901 git config --bool --get-urlmatch http.sslverify https://good.example.com >actual &&
1902 test_cmp expect actual &&
1905 echo http.cookiefile /tmp/cookie.txt &&
1906 echo http.sslverify false
1908 git config --get-urlmatch HTTP https://good.example.com >actual &&
1909 test_cmp expect actual &&
1911 echo http.sslverify >expect &&
1912 git config --get-urlmatch HTTP https://more.example.com.au >actual &&
1913 test_cmp expect actual
1916 # good section hygiene
1917 test_expect_success
'--unset last key removes section (except if commented)' '
1918 cat >.git/config <<-\EOF &&
1919 # some generic comment on the configuration file itself
1920 # a comment specific to this "section" section.
1922 # some intervening lines
1923 # that should also be dropped
1926 # please be careful when you update the above variable
1929 cat >expect <<-\EOF &&
1930 # some generic comment on the configuration file itself
1931 # a comment specific to this "section" section.
1933 # some intervening lines
1934 # that should also be dropped
1936 # please be careful when you update the above variable
1939 git config --unset section.key &&
1940 test_cmp expect .git/config &&
1942 cat >.git/config <<-\EOF &&
1948 cat >expect <<-\EOF &&
1952 git config --unset section.key &&
1953 test_cmp expect .git/config &&
1955 q_to_tab >.git/config <<-\EOF &&
1962 git config --unset two.key &&
1963 ! grep two .git/config &&
1965 q_to_tab >.git/config <<-\EOF &&
1972 git config --unset-all one.key &&
1973 test_line_count = 0 .git/config &&
1975 q_to_tab >.git/config <<-\EOF &&
1978 Q# a comment not at the start
1982 git config --unset two.key &&
1983 grep two .git/config &&
1985 q_to_tab >.git/config <<-\EOF &&
1987 Qkey = not [two "subsection"]
1994 git config --unset two.subsection.key &&
1995 test "not [two subsection]" = "$(git config one.key)" &&
1996 test_line_count = 3 .git/config
1999 test_expect_success
'--unset-all removes section if empty & uncommented' '
2000 cat >.git/config <<-\EOF &&
2006 git config --unset-all section.key &&
2007 test_line_count = 0 .git/config
2010 test_expect_success
'adding a key into an empty section reuses header' '
2011 cat >.git/config <<-\EOF &&
2015 q_to_tab >expect <<-\EOF &&
2020 git config section.key value &&
2021 test_cmp expect .git/config
2024 test_expect_success POSIXPERM
,PERL
'preserves existing permissions' '
2025 chmod 0600 .git/config &&
2026 git config imap.pass Hunter2 &&
2028 "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
2029 git config --rename-section imap pop &&
2031 "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
2034 ! test_have_prereq MINGW ||
2035 HOME
="$(pwd)" # convert to Windows path
2037 test_expect_success
'set up --show-origin tests' '
2038 INCLUDE_DIR="$HOME/include" &&
2039 mkdir -p "$INCLUDE_DIR" &&
2040 cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
2044 cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
2048 cat >"$HOME"/.gitconfig <<-EOF &&
2053 path = "$INCLUDE_DIR/absolute.include"
2055 cat >.git/config <<-\EOF
2060 path = ../include/relative.include
2064 test_expect_success
'--show-origin with --list' '
2065 cat >expect <<-EOF &&
2066 file:$HOME/.gitconfig user.global=true
2067 file:$HOME/.gitconfig user.override=global
2068 file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
2069 file:$INCLUDE_DIR/absolute.include user.absolute=include
2070 file:.git/config user.local=true
2071 file:.git/config user.override=local
2072 file:.git/config include.path=../include/relative.include
2073 file:.git/../include/relative.include user.relative=include
2074 command line: user.environ=true
2075 command line: user.cmdline=true
2077 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.environ GIT_CONFIG_VALUE_0=true\
2078 git -c user.cmdline=true config --list --show-origin >output &&
2079 test_cmp expect output
2082 test_expect_success
'--show-origin with --list --null' '
2083 cat >expect <<-EOF &&
2084 file:$HOME/.gitconfigQuser.global
2085 trueQfile:$HOME/.gitconfigQuser.override
2086 globalQfile:$HOME/.gitconfigQinclude.path
2087 $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
2088 includeQfile:.git/configQuser.local
2089 trueQfile:.git/configQuser.override
2090 localQfile:.git/configQinclude.path
2091 ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
2092 includeQcommand line:Quser.cmdline
2095 git -c user.cmdline=true config --null --list --show-origin >output.raw &&
2096 nul_to_q <output.raw >output &&
2097 # The here-doc above adds a newline that the --null output would not
2098 # include. Add it here to make the two comparable.
2100 test_cmp expect output
2103 test_expect_success
'--show-origin with single file' '
2104 cat >expect <<-\EOF &&
2105 file:.git/config user.local=true
2106 file:.git/config user.override=local
2107 file:.git/config include.path=../include/relative.include
2109 git config --local --list --show-origin >output &&
2110 test_cmp expect output
2113 test_expect_success
'--show-origin with --get-regexp' '
2114 cat >expect <<-EOF &&
2115 file:$HOME/.gitconfig user.global true
2116 file:.git/config user.local true
2118 git config --show-origin --get-regexp "user\.[g|l].*" >output &&
2119 test_cmp expect output
2122 test_expect_success
'--show-origin getting a single key' '
2123 cat >expect <<-\EOF &&
2124 file:.git/config local
2126 git config --show-origin user.override >output &&
2127 test_cmp expect output
2130 test_expect_success
'set up custom config file' '
2131 cat >"custom.conf" <<-\EOF &&
2135 CUSTOM_CONFIG_FILE="$(test-tool path-utils real_path custom.conf)"
2138 test_expect_success
!MINGW
'set up custom config file with special name characters' '
2139 WEIRDLY_NAMED_FILE="file\" (dq) and spaces.conf" &&
2140 cp "$CUSTOM_CONFIG_FILE" "$WEIRDLY_NAMED_FILE"
2143 test_expect_success
!MINGW
'--show-origin escape special file name characters' '
2144 cat >expect <<-\EOF &&
2145 file:"file\" (dq) and spaces.conf" user.custom=true
2147 git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
2148 test_cmp expect output
2151 test_expect_success
'--show-origin stdin' '
2152 cat >expect <<-\EOF &&
2153 standard input: user.custom=true
2155 git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
2156 test_cmp expect output
2159 test_expect_success
'--show-origin stdin with file include' '
2160 cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
2164 cat >expect <<-EOF &&
2165 file:$INCLUDE_DIR/stdin.include include
2167 echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" |
2168 git config --show-origin --includes --file - user.stdin >output &&
2170 test_cmp expect output
2173 test_expect_success
'--show-origin blob' '
2174 test_when_finished "rm -rf repo" &&
2178 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2179 cat >expect <<-EOF &&
2180 blob:$blob user.custom=true
2182 git config --blob=$blob --show-origin --list >output &&
2183 test_cmp expect output
2187 test_expect_success
'--show-origin blob ref' '
2188 test_when_finished "rm -rf repo" &&
2192 cat >expect <<-\EOF &&
2193 blob:main:custom.conf user.custom=true
2195 cp "$CUSTOM_CONFIG_FILE" custom.conf &&
2196 git add custom.conf &&
2197 git commit -m "new config file" &&
2198 git config --blob=main:custom.conf --show-origin --list >output &&
2199 test_cmp expect output
2203 test_expect_success
'--show-origin with --default' '
2204 git config --show-origin --default foo some.key >actual &&
2205 echo "command line: foo" >expect &&
2206 test_cmp expect actual
2209 test_expect_success
'--show-scope with --list' '
2210 cat >expect <<-EOF &&
2211 global user.global=true
2212 global user.override=global
2213 global include.path=$INCLUDE_DIR/absolute.include
2214 global user.absolute=include
2215 local user.local=true
2216 local user.override=local
2217 local include.path=../include/relative.include
2218 local user.relative=include
2219 local core.repositoryformatversion=1
2220 local extensions.worktreeconfig=true
2221 worktree user.worktree=true
2222 command user.cmdline=true
2224 git worktree add wt1 &&
2225 # We need these to test for worktree scope, but outside of this
2226 # test, this is just noise
2227 test_config core.repositoryformatversion 1 &&
2228 test_config extensions.worktreeConfig true &&
2229 git config --worktree user.worktree true &&
2230 git -c user.cmdline=true config --list --show-scope >output &&
2231 test_cmp expect output
2234 test_expect_success
!MINGW
'--show-scope with --blob' '
2235 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2236 cat >expect <<-EOF &&
2237 command user.custom=true
2239 git config --blob=$blob --show-scope --list >output &&
2240 test_cmp expect output
2243 test_expect_success
'--show-scope with --local' '
2244 cat >expect <<-\EOF &&
2245 local user.local=true
2246 local user.override=local
2247 local include.path=../include/relative.include
2249 git config --local --list --show-scope >output &&
2250 test_cmp expect output
2253 test_expect_success
'--show-scope getting a single value' '
2254 cat >expect <<-\EOF &&
2257 git config --show-scope --get user.local >output &&
2258 test_cmp expect output
2261 test_expect_success
'--show-scope with --show-origin' '
2262 cat >expect <<-EOF &&
2263 global file:$HOME/.gitconfig user.global=true
2264 global file:$HOME/.gitconfig user.override=global
2265 global file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
2266 global file:$INCLUDE_DIR/absolute.include user.absolute=include
2267 local file:.git/config user.local=true
2268 local file:.git/config user.override=local
2269 local file:.git/config include.path=../include/relative.include
2270 local file:.git/../include/relative.include user.relative=include
2271 command command line: user.cmdline=true
2273 git -c user.cmdline=true config --list --show-origin --show-scope >output &&
2274 test_cmp expect output
2277 test_expect_success
'--show-scope with --default' '
2278 git config --show-scope --default foo some.key >actual &&
2279 echo "command foo" >expect &&
2280 test_cmp expect actual
2283 test_expect_success
'override global and system config' '
2284 test_when_finished rm -f \"\$HOME\"/.gitconfig &&
2285 cat >"$HOME"/.gitconfig <<-EOF &&
2290 test_when_finished rm -rf \"\$HOME\"/.config/git &&
2291 mkdir -p "$HOME"/.config/git &&
2292 cat >"$HOME"/.config/git/config <<-EOF &&
2296 cat >.git/config <<-EOF &&
2300 cat >custom-global-config <<-EOF &&
2304 cat >custom-system-config <<-EOF &&
2309 cat >expect <<-EOF &&
2310 global xdg.config=true
2311 global home.config=true
2312 local local.config=true
2314 git config --show-scope --list >output &&
2315 test_cmp expect output &&
2317 cat >expect <<-EOF &&
2318 system system.config=true
2319 global global.config=true
2320 local local.config=true
2322 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
2323 git config --show-scope --list >output &&
2324 test_cmp expect output &&
2326 cat >expect <<-EOF &&
2327 local local.config=true
2329 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \
2330 git config --show-scope --list >output &&
2331 test_cmp expect output
2334 test_expect_success
'override global and system config with missing file' '
2335 test_must_fail env GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=/dev/null git config --global --list &&
2336 test_must_fail env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=does-not-exist git config --system --list &&
2337 GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=does-not-exist git version
2340 test_expect_success
'system override has no effect with GIT_CONFIG_NOSYSTEM' '
2341 # `git config --system` has different semantics compared to other
2342 # commands as it ignores GIT_CONFIG_NOSYSTEM. We thus test whether the
2343 # variable has an effect via a different proxy.
2344 cat >alias-config <<-EOF &&
2346 hello-world = !echo "hello world"
2348 test_must_fail env GIT_CONFIG_NOSYSTEM=true GIT_CONFIG_SYSTEM=alias-config \
2350 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=alias-config \
2351 git hello-world >actual &&
2352 echo "hello world" >expect &&
2353 test_cmp expect actual
2356 test_expect_success
'write to overridden global and system config' '
2357 cat >expect <<EOF &&
2362 GIT_CONFIG_GLOBAL=write-to-global git config --global config.key value &&
2363 test_cmp expect write-to-global &&
2365 GIT_CONFIG_SYSTEM=write-to-system git config --system config.key value &&
2366 test_cmp expect write-to-system
2369 for opt
in --local --worktree
2371 test_expect_success
"$opt requires a repo" '
2372 # we expect 128 to ensure that we do not simply
2373 # fail to find anything and return code "1"
2374 test_expect_code 128 nongit git config $opt foo.bar
2378 cat >.git
/config
<<-\EOF &&
2385 test_expect_success 'identical modern --type specifiers are allowed' '
2386 test_cmp_config 1048576 --type=int --type=int section.big
2389 test_expect_success 'identical legacy --type specifiers are allowed' '
2390 test_cmp_config 1048576 --int --int section.big
2393 test_expect_success 'identical mixed --type specifiers are allowed' '
2394 test_cmp_config 1048576 --int --type=int section.big
2397 test_expect_success 'non-identical modern --type specifiers are not allowed' '
2398 test_must_fail git config --type=int --type=bool section.big 2>error &&
2399 test_grep "only one type at a time" error
2402 test_expect_success 'non-identical legacy --type specifiers are not allowed' '
2403 test_must_fail git config --int --bool section.big 2>error &&
2404 test_grep "only one type at a time" error
2407 test_expect_success 'non-identical mixed --type specifiers are not allowed' '
2408 test_must_fail git config --type=int --bool section.big 2>error &&
2409 test_grep "only one type at a time" error
2412 test_expect_success '--type allows valid type specifiers' '
2413 test_cmp_config true --type=bool section.foo
2416 test_expect_success '--no-type unsets type specifiers' '
2417 test_cmp_config 10 --type=bool --no-type section.number
2420 test_expect_success 'unset type specifiers may be reset to conflicting ones' '
2421 test_cmp_config 1048576 --type=bool --no-type --type=int section.big
2424 test_expect_success '--type rejects unknown specifiers' '
2425 test_must_fail git config --type=nonsense section.foo 2>error &&
2426 test_grep "unrecognized --type argument" error
2429 test_expect_success '--type=int requires at least one digit' '
2430 test_must_fail git config --type int --default m some.key >out 2>error &&
2431 grep "bad numeric config value" error &&
2432 test_must_be_empty out
2435 test_expect_success '--replace-all does not invent newlines' '
2436 q_to_tab >.git/config <<-\
EOF &&
2444 q_to_tab >expect <<-\EOF &&
2452 git config --replace-all abc.key b &&
2453 test_cmp expect .git/config
2456 test_expect_success 'set all config with value-pattern' '
2457 test_when_finished rm -f config initial &&
2458 git config --file=initial abc.key one &&
2460 # no match => add new entry
2461 cp initial config &&
2462 git config --file=config abc.key two a+ &&
2463 git config --file=config --list >actual &&
2464 cat >expect <<-\EOF &&
2468 test_cmp expect actual &&
2470 # multiple matches => failure
2471 test_must_fail git config --file=config abc.key three o+ 2>err &&
2472 test_grep "has multiple values" err &&
2474 # multiple values, no match => add
2475 git config --file=config abc.key three a+ &&
2476 git config --file=config --list >actual &&
2477 cat >expect <<-\EOF &&
2482 test_cmp expect actual &&
2484 # single match => replace
2485 git config --file=config abc.key four h+ &&
2486 git config --file=config --list >actual &&
2487 cat >expect <<-\EOF &&
2492 test_cmp expect actual
2495 test_expect_success '--replace-all and value-pattern' '
2496 test_when_finished rm -f config &&
2497 git config --file=config --add abc.key one &&
2498 git config --file=config --add abc.key two &&
2499 git config --file=config --add abc.key three &&
2500 git config --file=config --replace-all abc.key four "o+" &&
2501 git config --file=config --list >actual &&
2502 cat >expect <<-\EOF &&
2506 test_cmp expect actual
2509 test_expect_success 'refuse --fixed-value for incompatible actions' '
2510 test_when_finished rm -f config &&
2511 git config --file=config dev.null bogus &&
2513 # These modes do not allow --fixed-value at all
2514 test_must_fail git config --file=config --fixed-value --add dev.null bogus &&
2515 test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus &&
2516 test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus &&
2517 test_must_fail git config --file=config --fixed-value --rename-section dev null &&
2518 test_must_fail git config --file=config --fixed-value --remove-section dev &&
2519 test_must_fail git config --file=config --fixed-value --list &&
2520 test_must_fail git config --file=config --fixed-value --get-color dev.null &&
2521 test_must_fail git config --file=config --fixed-value --get-colorbool dev.null &&
2523 # These modes complain when --fixed-value has no value-pattern
2524 test_must_fail git config --file=config --fixed-value dev.null bogus &&
2525 test_must_fail git config --file=config --fixed-value --replace-all dev.null bogus &&
2526 test_must_fail git config --file=config --fixed-value --get dev.null &&
2527 test_must_fail git config --file=config --fixed-value --get-all dev.null &&
2528 test_must_fail git config --file=config --fixed-value --get-regexp "dev.*" &&
2529 test_must_fail git config --file=config --fixed-value --unset dev.null &&
2530 test_must_fail git config --file=config --fixed-value --unset-all dev.null
2533 test_expect_success '--fixed-value uses exact string matching' '
2534 test_when_finished rm -f config initial &&
2535 META="a+b*c?d[e]f.g" &&
2536 git config --file=initial fixed.test "$META" &&
2538 cp initial config &&
2539 git config --file=config fixed.test bogus "$META" &&
2540 git config --file=config --list >actual &&
2541 cat >expect <<-EOF &&
2545 test_cmp expect actual &&
2547 cp initial config &&
2548 git config --file=config --fixed-value fixed.test bogus "$META" &&
2549 git config --file=config --list >actual &&
2550 cat >expect <<-\EOF &&
2553 test_cmp expect actual &&
2555 cp initial config &&
2556 test_must_fail git config --file=config --unset fixed.test "$META" &&
2557 git config --file=config --fixed-value --unset fixed.test "$META" &&
2558 test_must_fail git config --file=config fixed.test &&
2560 cp initial config &&
2561 test_must_fail git config --file=config --unset-all fixed.test "$META" &&
2562 git config --file=config --fixed-value --unset-all fixed.test "$META" &&
2563 test_must_fail git config --file=config fixed.test &&
2565 cp initial config &&
2566 git config --file=config --replace-all fixed.test bogus "$META" &&
2567 git config --file=config --list >actual &&
2568 cat >expect <<-EOF &&
2572 test_cmp expect actual &&
2574 git config --file=config --fixed-value --replace-all fixed.test bogus "$META" &&
2575 git config --file=config --list >actual &&
2576 cat >expect <<-EOF &&
2580 test_cmp expect actual
2583 test_expect_success '--get and --get-all with --fixed-value' '
2584 test_when_finished rm -f config &&
2585 META="a+b*c?d[e]f.g" &&
2586 git config --file=config fixed.test bogus &&
2587 git config --file=config --add fixed.test "$META" &&
2589 git config --file=config --get fixed.test bogus &&
2590 test_must_fail git config --file=config --get fixed.test "$META" &&
2591 git config --file=config --get --fixed-value fixed.test "$META" &&
2592 test_must_fail git config --file=config --get --fixed-value fixed.test non-existent &&
2594 git config --file=config --get-all fixed.test bogus &&
2595 test_must_fail git config --file=config --get-all fixed.test "$META" &&
2596 git config --file=config --get-all --fixed-value fixed.test "$META" &&
2597 test_must_fail git config --file=config --get-all --fixed-value fixed.test non-existent &&
2599 git config --file=config --get-regexp fixed+ bogus &&
2600 test_must_fail git config --file=config --get-regexp fixed+ "$META" &&
2601 git config --file=config --get-regexp --fixed-value fixed+ "$META" &&
2602 test_must_fail git config --file=config --get-regexp --fixed-value fixed+ non-existent
2605 test_expect_success 'includeIf.hasconfig:remote.*.url' '
2606 git init hasremoteurlTest &&
2607 test_when_finished "rm -rf hasremoteurlTest" &&
2609 cat >include-this <<-\EOF &&
2611 this = this-is-included
2613 cat >dont-include-that <<-\EOF &&
2615 that = that-is-not-included
2617 cat >>hasremoteurlTest/.git/config <<-EOF &&
2618 [includeIf "hasconfig:remote.*.url:foourl"]
2619 path = "$(pwd)/include-this"
2620 [includeIf "hasconfig:remote.*.url:barurl"]
2621 path = "$(pwd)/dont-include-that"
2626 echo this-is-included >expect-this &&
2627 git -C hasremoteurlTest config --get user.this >actual-this &&
2628 test_cmp expect-this actual-this &&
2630 test_must_fail git -C hasremoteurlTest config --get user.that
2633 test_expect_success 'includeIf.hasconfig:remote.*.url respects last-config-wins' '
2634 git init hasremoteurlTest &&
2635 test_when_finished "rm -rf hasremoteurlTest" &&
2637 cat >include-two-three <<-\EOF &&
2639 two = included-config
2640 three = included-config
2642 cat >>hasremoteurlTest/.git/config <<-EOF &&
2648 [includeIf "hasconfig:remote.*.url:foourl"]
2649 path = "$(pwd)/include-two-three"
2654 echo main-config >expect-main-config &&
2655 echo included-config >expect-included-config &&
2657 git -C hasremoteurlTest config --get user.one >actual &&
2658 test_cmp expect-main-config actual &&
2660 git -C hasremoteurlTest config --get user.two >actual &&
2661 test_cmp expect-included-config actual &&
2663 git -C hasremoteurlTest config --get user.three >actual &&
2664 test_cmp expect-main-config actual
2667 test_expect_success 'includeIf.hasconfig:remote.*.url globs' '
2668 git init hasremoteurlTest &&
2669 test_when_finished "rm -rf hasremoteurlTest" &&
2671 printf "[user]\ndss = yes\n" >double-star-start &&
2672 printf "[user]\ndse = yes\n" >double-star-end &&
2673 printf "[user]\ndsm = yes\n" >double-star-middle &&
2674 printf "[user]\nssm = yes\n" >single-star-middle &&
2675 printf "[user]\nno = no\n" >no &&
2677 cat >>hasremoteurlTest/.git/config <<-EOF &&
2679 url = https://foo/bar/baz
2680 [includeIf "hasconfig:remote.*.url:**/baz"]
2681 path = "$(pwd)/double-star-start"
2682 [includeIf "hasconfig:remote.*.url:**/nomatch"]
2684 [includeIf "hasconfig:remote.*.url:https:/**"]
2685 path = "$(pwd)/double-star-end"
2686 [includeIf "hasconfig:remote.*.url:nomatch:/**"]
2688 [includeIf "hasconfig:remote.*.url:https:/**/baz"]
2689 path = "$(pwd)/double-star-middle"
2690 [includeIf "hasconfig:remote.*.url:https:/**/nomatch"]
2692 [includeIf "hasconfig:remote.*.url:https://*/bar/baz"]
2693 path = "$(pwd)/single-star-middle"
2694 [includeIf "hasconfig:remote.*.url:https://*/baz"]
2698 git -C hasremoteurlTest config --get user.dss &&
2699 git -C hasremoteurlTest config --get user.dse &&
2700 git -C hasremoteurlTest config --get user.dsm &&
2701 git -C hasremoteurlTest config --get user.ssm &&
2702 test_must_fail git -C hasremoteurlTest config --get user.no
2705 test_expect_success 'includeIf.hasconfig:remote.*.url forbids remote url in such included files' '
2706 git init hasremoteurlTest &&
2707 test_when_finished "rm -rf hasremoteurlTest" &&
2709 cat >include-with-url <<-\EOF &&
2713 cat >>hasremoteurlTest/.git/config <<-EOF &&
2714 [includeIf "hasconfig:remote.*.url:foourl"]
2715 path = "$(pwd)/include-with-url"
2718 # test with any Git command
2719 test_must_fail git -C hasremoteurlTest status 2>err &&
2720 grep "fatal: remote URLs cannot be configured in file directly or indirectly included by includeIf.hasconfig:remote.*.url" err