3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test git config in different settings'
10 test_expect_success 'clear default config' '
18 test_expect_success 'initial' '
19 git config core.penguin "little blue" &&
20 test_cmp expect .git/config
28 test_expect_success 'mixed case' '
29 git config Core.Movie BadPhysics &&
30 test_cmp expect .git/config
40 test_expect_success 'similar section' '
41 git config Cores.WhatEver Second &&
42 test_cmp expect .git/config
53 test_expect_success 'uppercase section' '
54 git config CORE.UPPERCASE true &&
55 test_cmp expect .git/config
58 test_expect_success 'replace with non-match' '
59 git config core.penguin kingpin !blue
62 test_expect_success 'replace with non-match (actually matching)' '
63 git config core.penguin "very blue" !kingpin
76 test_expect_success 'non-match result' 'test_cmp expect .git/config'
78 test_expect_success 'find mixed-case key by canonical name' '
79 echo Second >expect &&
80 git config cores.whatever >actual &&
81 test_cmp expect actual
84 test_expect_success 'find mixed-case key by non-canonical name' '
85 echo Second >expect &&
86 git config CoReS.WhAtEvEr >actual &&
87 test_cmp expect actual
90 test_expect_success 'subsections are not canonicalized by git-config' '
91 cat >>.git/config <<-\EOF &&
94 [section "SubSection"]
98 git config section.subsection.key >actual &&
99 test_cmp expect actual &&
101 git config section.SubSection.key >actual &&
102 test_cmp expect actual
105 cat > .git/config <<\EOF
113 test_expect_success 'unset with cont. lines' '
114 git config --unset beta.baz
123 test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config'
125 cat > .git/config << EOF
126 [beta] ; silly comment # another comment
127 noIndent= sillyValue ; 'nother silly comment
131 haha ="beta" # last silly comment
134 [nextSection] noNewline = ouch
137 cp .git/config .git/config2
139 test_expect_success 'multiple unset' '
140 git config --unset-all beta.haha
144 [beta] ; silly comment # another comment
145 noIndent= sillyValue ; 'nother silly comment
149 [nextSection] noNewline = ouch
152 test_expect_success 'multiple unset is correct' '
153 test_cmp expect .git/config
156 cp .git/config2 .git/config
158 test_expect_success '--replace-all missing value' '
159 test_must_fail git config --replace-all beta.haha &&
160 test_cmp .git/config2 .git/config
165 test_expect_success '--replace-all' '
166 git config --replace-all beta.haha gamma
170 [beta] ; silly comment # another comment
171 noIndent= sillyValue ; 'nother silly comment
176 [nextSection] noNewline = ouch
179 test_expect_success 'all replaced' '
180 test_cmp expect .git/config
184 [beta] ; silly comment # another comment
185 noIndent= sillyValue ; 'nother silly comment
190 [nextSection] noNewline = ouch
192 test_expect_success 'really mean test' '
193 git config beta.haha alpha &&
194 test_cmp expect .git/config
198 [beta] ; silly comment # another comment
199 noIndent= sillyValue ; 'nother silly comment
207 test_expect_success 'really really mean test' '
208 git config nextsection.nonewline wow &&
209 test_cmp expect .git/config
212 test_expect_success 'get value' '
213 echo alpha >expect &&
214 git config beta.haha >actual &&
215 test_cmp expect actual
219 [beta] ; silly comment # another comment
220 noIndent= sillyValue ; 'nother silly comment
227 test_expect_success 'unset' '
228 git config --unset beta.haha &&
229 test_cmp expect .git/config
233 [beta] ; silly comment # another comment
234 noIndent= sillyValue ; 'nother silly comment
240 NoNewLine = wow2 for me
242 test_expect_success 'multivar' '
243 git config nextsection.NoNewLine "wow2 for me" "for me$" &&
244 test_cmp expect .git/config
247 test_expect_success 'non-match' '
248 git config --get nextsection.nonewline !for
251 test_expect_success 'non-match value' '
253 git config --get nextsection.nonewline !for >actual &&
254 test_cmp expect actual
257 test_expect_success 'multi-valued get returns final one' '
258 echo "wow2 for me" >expect &&
259 git config --get nextsection.nonewline >actual &&
260 test_cmp expect actual
263 test_expect_success 'multi-valued get-all returns all' '
264 cat >expect <<-\EOF &&
268 git config --get-all nextsection.nonewline >actual &&
269 test_cmp expect actual
273 [beta] ; silly comment # another comment
274 noIndent= sillyValue ; 'nother silly comment
280 NoNewLine = wow2 for me
282 test_expect_success 'multivar replace' '
283 git config nextsection.nonewline "wow3" "wow$" &&
284 test_cmp expect .git/config
287 test_expect_success 'ambiguous unset' '
288 test_must_fail git config --unset nextsection.nonewline
291 test_expect_success 'invalid unset' '
292 test_must_fail git config --unset somesection.nonewline
296 [beta] ; silly comment # another comment
297 noIndent= sillyValue ; 'nother silly comment
302 NoNewLine = wow2 for me
305 test_expect_success 'multivar unset' '
306 git config --unset nextsection.nonewline "wow3$" &&
307 test_cmp expect .git/config
310 test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
312 test_expect_success 'correct key' 'git config 123456.a123 987'
314 test_expect_success 'hierarchical section' '
315 git config Version.1.2.3eX.Alpha beta
319 [beta] ; silly comment # another comment
320 noIndent= sillyValue ; 'nother silly comment
325 NoNewLine = wow2 for me
332 test_expect_success 'hierarchical section value' '
333 test_cmp expect .git/config
344 beta.noindent=sillyValue
345 nextsection.nonewline=wow2 for me
347 version.1.2.3eX.alpha=beta
350 test_expect_success 'working --list' '
351 git config --list > output &&
352 test_cmp expect output
364 test_expect_success '--list without repo produces empty output' '
365 git --git-dir=nonexistent config --list >output &&
366 test_cmp expect output
378 nextsection.nonewline
380 version.1.2.3eX.alpha
383 test_expect_success '--name-only --list' '
384 git config --name-only --list >output &&
385 test_cmp expect output
389 beta.noindent sillyValue
390 nextsection.nonewline wow2 for me
393 test_expect_success '--get-regexp' '
394 git config --get-regexp in >output &&
395 test_cmp expect output
400 nextsection.nonewline
403 test_expect_success '--name-only --get-regexp' '
404 git config --name-only --get-regexp in >output &&
405 test_cmp expect output
413 test_expect_success '--add' '
414 git config --add nextsection.nonewline "wow4 for you" &&
415 git config --get-all nextsection.nonewline > output &&
416 test_cmp expect output
419 cat > .git/config << EOF
426 test_expect_success 'get variable with no value' '
427 git config --get novalue.variable ^$
430 test_expect_success 'get variable with empty value' '
431 git config --get emptyvalue.variable ^$
434 echo novalue.variable > expect
436 test_expect_success 'get-regexp variable with no value' '
437 git config --get-regexp novalue > output &&
438 test_cmp expect output
441 echo 'novalue.variable true' > expect
443 test_expect_success 'get-regexp --bool variable with no value' '
444 git config --bool --get-regexp novalue > output &&
445 test_cmp expect output
448 echo 'emptyvalue.variable ' > expect
450 test_expect_success 'get-regexp variable with empty value' '
451 git config --get-regexp emptyvalue > output &&
452 test_cmp expect output
457 test_expect_success 'get bool variable with no value' '
458 git config --bool novalue.variable > output &&
459 test_cmp expect output
464 test_expect_success 'get bool variable with empty value' '
465 git config --bool emptyvalue.variable > output &&
466 test_cmp expect output
469 test_expect_success 'no arguments, but no crash' '
470 test_must_fail git config >output 2>&1 &&
471 test_i18ngrep usage output
474 cat > .git/config << EOF
486 test_expect_success 'new section is partial match of another' '
488 test_cmp expect .git/config
501 test_expect_success 'new variable inserts into proper section' '
504 test_cmp expect .git/config
507 test_expect_success 'alternative --file (non-existing file should fail)' '
508 test_must_fail git config --file non-existing-config -l
511 cat > other-config << EOF
520 test_expect_success 'alternative GIT_CONFIG' '
521 GIT_CONFIG=other-config git config --list >output &&
522 test_cmp expect output
525 test_expect_success 'alternative GIT_CONFIG (--file)' '
526 git config --file other-config --list >output &&
527 test_cmp expect output
530 test_expect_success 'alternative GIT_CONFIG (--file=-)' '
531 git config --file - --list <other-config >output &&
532 test_cmp expect output
535 test_expect_success 'setting a value in stdin is an error' '
536 test_must_fail git config --file - some.value foo
539 test_expect_success 'editing stdin is an error' '
540 test_must_fail git config --file - --edit
543 test_expect_success 'refer config from subdirectory' '
547 echo strasse >expect &&
548 git config --get --file ../other-config ein.bahn >actual &&
549 test_cmp expect actual
554 test_expect_success 'refer config from subdirectory via --file' '
557 git config --file=../other-config --get ein.bahn >actual &&
558 test_cmp expect actual
569 test_expect_success '--set in alternative file' '
570 git config --file=other-config anwohner.park ausweis &&
571 test_cmp expect other-config
574 cat > .git/config << EOF
581 [branch "1 234 blabl/a"]
585 test_expect_success 'rename section' '
586 git config --rename-section branch.eins branch.zwei
596 [branch "1 234 blabl/a"]
600 test_expect_success 'rename succeeded' '
601 test_cmp expect .git/config
604 test_expect_success 'rename non-existing section' '
605 test_must_fail git config --rename-section \
606 branch."world domination" branch.drei
609 test_expect_success 'rename succeeded' '
610 test_cmp expect .git/config
613 test_expect_success 'rename another section' '
614 git config --rename-section branch."1 234 blabl/a" branch.drei
628 test_expect_success 'rename succeeded' '
629 test_cmp expect .git/config
632 cat >> .git/config << EOF
633 [branch "vier"] z = 1
636 test_expect_success 'rename a section with a var on the same line' '
637 git config --rename-section branch.vier branch.zwei
653 test_expect_success 'rename succeeded' '
654 test_cmp expect .git/config
657 test_expect_success 'renaming empty section name is rejected' '
658 test_must_fail git config --rename-section branch.zwei ""
661 test_expect_success 'renaming to bogus section is rejected' '
662 test_must_fail git config --rename-section branch.zwei "bogus name"
665 cat >> .git/config << EOF
666 [branch "zwei"] a = 1 [branch "vier"]
669 test_expect_success 'remove section' '
670 git config --remove-section branch.zwei
680 test_expect_success 'section was removed properly' '
681 test_cmp expect .git/config
687 dbname = %Ggitcvs2.%a.%m.sqlite
689 dbname = %Ggitcvs1.%a.%m.sqlite
692 test_expect_success 'section ending' '
694 git config gitcvs.enabled true &&
695 git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
696 git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
697 test_cmp expect .git/config
701 test_expect_success numbers '
702 git config kilo.gram 1k &&
703 git config mega.ton 1m &&
705 echo 1048576 >>expect &&
706 git config --int --get kilo.gram >actual &&
707 git config --int --get mega.ton >>actual &&
708 test_cmp expect actual
711 test_expect_success '--int is at least 64 bits' '
712 git config giga.watts 121g &&
713 echo 129922760704 >expect &&
714 git config --int --get giga.watts >actual &&
715 test_cmp expect actual
718 test_expect_success 'invalid unit' '
719 git config aninvalid.unit "1auto" &&
720 echo 1auto >expect &&
721 git config aninvalid.unit >actual &&
722 test_cmp expect actual &&
723 test_must_fail git config --int --get aninvalid.unit 2>actual &&
724 test_i18ngrep "bad numeric config value .1auto. for .aninvalid.unit. in file .git/config: invalid unit" actual
727 test_expect_success 'invalid stdin config' '
728 echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
729 test_i18ngrep "bad config line 1 in standard input" output
743 test_expect_success bool '
745 git config bool.true1 01 &&
746 git config bool.true2 -1 &&
747 git config bool.true3 YeS &&
748 git config bool.true4 true &&
749 git config bool.false1 000 &&
750 git config bool.false2 "" &&
751 git config bool.false3 nO &&
752 git config bool.false4 FALSE &&
756 git config --bool --get bool.true$i >>result
757 git config --bool --get bool.false$i >>result
759 test_cmp expect result'
761 test_expect_success 'invalid bool (--get)' '
763 git config bool.nobool foobar &&
764 test_must_fail git config --bool --get bool.nobool'
766 test_expect_success 'invalid bool (set)' '
768 test_must_fail git config --bool bool.nobool foobar'
782 test_expect_success 'set --bool' '
785 git config --bool bool.true1 01 &&
786 git config --bool bool.true2 -1 &&
787 git config --bool bool.true3 YeS &&
788 git config --bool bool.true4 true &&
789 git config --bool bool.false1 000 &&
790 git config --bool bool.false2 "" &&
791 git config --bool bool.false3 nO &&
792 git config --bool bool.false4 FALSE &&
793 test_cmp expect .git/config'
802 test_expect_success 'set --int' '
805 git config --int int.val1 01 &&
806 git config --int int.val2 -1 &&
807 git config --int int.val3 5m &&
808 test_cmp expect .git/config
811 test_expect_success 'get --bool-or-int' '
812 cat >.git/config <<-\EOF &&
822 cat >expect <<-\EOF &&
831 git config --bool-or-int bool.true1 &&
832 git config --bool-or-int bool.true2 &&
833 git config --bool-or-int bool.false &&
834 git config --bool-or-int int.int1 &&
835 git config --bool-or-int int.int2 &&
836 git config --bool-or-int int.int3
838 test_cmp expect actual
853 test_expect_success 'set --bool-or-int' '
855 git config --bool-or-int bool.true1 true &&
856 git config --bool-or-int bool.false1 false &&
857 git config --bool-or-int bool.true2 yes &&
858 git config --bool-or-int bool.false2 no &&
859 git config --bool-or-int int.int1 0 &&
860 git config --bool-or-int int.int2 1 &&
861 git config --bool-or-int int.int3 -1 &&
862 test_cmp expect .git/config
872 test_expect_success !MINGW 'set --path' '
874 git config --path path.home "~/" &&
875 git config --path path.normal "/dev/null" &&
876 git config --path path.trailingtilde "foo~" &&
877 test_cmp expect .git/config'
879 if test_have_prereq !MINGW && test "${HOME+set}"
881 test_set_prereq HOMEVAR
890 test_expect_success HOMEVAR 'get --path' '
891 git config --get --path path.home > result &&
892 git config --get --path path.normal >> result &&
893 git config --get --path path.trailingtilde >> result &&
894 test_cmp expect result
902 test_expect_success !MINGW 'get --path copes with unset $HOME' '
905 test_must_fail git config --get --path path.home \
907 git config --get --path path.normal >>result &&
908 git config --get --path path.trailingtilde >>result
910 grep "[Ff]ailed to expand.*~/" msg &&
911 test_cmp expect result
914 test_expect_success 'get --path barfs on boolean variable' '
915 echo "[path]bool" >.git/config &&
916 test_must_fail git config --get --path path.bool
923 semicolon = "test;test"
926 test_expect_success 'quoting' '
928 git config quote.leading " test" &&
929 git config quote.ending "test " &&
930 git config quote.semicolon "test;test" &&
931 git config quote.hash "test#test" &&
932 test_cmp expect .git/config
935 test_expect_success 'key with newline' '
936 test_must_fail git config "key.with
939 test_expect_success 'value with newline' 'git config key.sub value.with\\\
942 cat > .git/config <<\EOF
947 noncont = not continued ; \
960 section.continued=continued
961 section.noncont=not continued
962 section.quotecont=cont;inued
965 test_expect_success 'value continued on next line' '
966 git config --list > result &&
967 test_cmp result expect
970 cat > .git/config <<\EOF
971 [section "sub=section"]
987 mergetoolQsection.sub=section.val1
988 foo=barQsection.sub=section.val2
990 barQsection.sub=section.val3
993 Qsection.sub=section.val4
994 Qsection.sub=section.val5Q
996 test_expect_success '--null --list' '
997 git config --null --list >result.raw &&
998 nul_to_q <result.raw >result &&
1000 test_cmp expect result
1004 section.sub=section.val1
1005 foo=barQsection.sub=section.val2
1007 barQsection.sub=section.val3
1010 Qsection.sub=section.val4
1011 Qsection.sub=section.val5Q
1013 test_expect_success '--null --get-regexp' '
1014 git config --null --get-regexp "val[0-9]" >result.raw &&
1015 nul_to_q <result.raw >result &&
1017 test_cmp expect result
1020 test_expect_success 'inner whitespace kept verbatim' '
1021 git config section.val "foo bar" &&
1022 echo "foo bar" >expect &&
1023 git config section.val >actual &&
1024 test_cmp expect actual
1027 test_expect_success SYMLINKS 'symlinked configuration' '
1028 ln -s notyet myconfig &&
1029 git config --file=myconfig test.frotz nitfol &&
1032 test "z$(git config --file=notyet test.frotz)" = znitfol &&
1033 git config --file=myconfig test.xyzzy rezrov &&
1036 cat >expect <<-\EOF &&
1041 git config --file=notyet test.frotz &&
1042 git config --file=notyet test.xyzzy
1044 test_cmp expect actual
1047 test_expect_success 'nonexistent configuration' '
1048 test_must_fail git config --file=doesnotexist --list &&
1049 test_must_fail git config --file=doesnotexist test.xyzzy
1052 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
1053 ln -s doesnotexist linktonada &&
1054 ln -s linktonada linktolinktonada &&
1055 test_must_fail git config --file=linktonada --list &&
1056 test_must_fail git config --file=linktolinktonada --list
1059 test_expect_success 'check split_cmdline return' "
1060 git config alias.split-cmdline-fix 'echo \"' &&
1061 test_must_fail git split-cmdline-fix &&
1064 git commit -m 'initial commit' &&
1065 git config branch.master.mergeoptions 'echo \"' &&
1066 test_must_fail git merge master
1069 test_expect_success 'git -c "key=value" support' '
1070 cat >expect <<-\EOF &&
1076 git -c core.name=value config core.name &&
1077 git -c foo.CamelCase=value config foo.camelcase &&
1078 git -c foo.flag config --bool foo.flag
1080 test_cmp expect actual &&
1081 test_must_fail git -c name=value config core.name
1084 # We just need a type-specifier here that cares about the
1085 # distinction internally between a NULL boolean and a real
1086 # string (because most of git's internal parsers do care).
1087 # Using "--path" works, but we do not otherwise care about
1089 test_expect_success 'git -c can represent empty string' '
1091 git -c foo.empty= config --path foo.empty >actual &&
1092 test_cmp expect actual
1095 test_expect_success 'key sanity-checking' '
1096 test_must_fail git config foo=bar &&
1097 test_must_fail git config foo=.bar &&
1098 test_must_fail git config foo.ba=r &&
1099 test_must_fail git config foo.1bar &&
1100 test_must_fail git config foo."ba
1102 test_must_fail git config . false &&
1103 test_must_fail git config .foo false &&
1104 test_must_fail git config foo. false &&
1105 test_must_fail git config .foo. false &&
1106 git config foo.bar true &&
1107 git config foo."ba =z".bar false
1110 test_expect_success 'git -c works with aliases of builtins' '
1111 git config alias.checkconfig "-c foo.check=bar config foo.check" &&
1113 git checkconfig >actual &&
1114 test_cmp expect actual
1117 test_expect_success 'git -c does not split values on equals' '
1118 echo "value with = in it" >expect &&
1119 git -c core.foo="value with = in it" config core.foo >actual &&
1120 test_cmp expect actual
1123 test_expect_success 'git -c dies on bogus config' '
1124 test_must_fail git -c core.bare=foo rev-parse
1127 test_expect_success 'git -c complains about empty key' '
1128 test_must_fail git -c "=foo" rev-parse
1131 test_expect_success 'git -c complains about empty key and value' '
1132 test_must_fail git -c "" rev-parse
1135 test_expect_success 'git config --edit works' '
1136 git config -f tmp test.value no &&
1137 echo test.value=yes >expect &&
1138 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1139 git config -f tmp --list >actual &&
1140 test_cmp expect actual
1143 test_expect_success 'git config --edit respects core.editor' '
1144 git config -f tmp test.value no &&
1145 echo test.value=yes >expect &&
1146 test_config core.editor "echo [test]value=yes >" &&
1147 git config -f tmp --edit &&
1148 git config -f tmp --list >actual &&
1149 test_cmp expect actual
1152 # malformed configuration files
1153 test_expect_success 'barf on syntax error' '
1154 cat >.git/config <<-\EOF &&
1155 # broken section line
1159 test_must_fail git config --get section.key >actual 2>error &&
1160 grep " line 3 " error
1163 test_expect_success 'barf on incomplete section header' '
1164 cat >.git/config <<-\EOF &&
1165 # broken section line
1169 test_must_fail git config --get section.key >actual 2>error &&
1170 grep " line 2 " error
1173 test_expect_success 'barf on incomplete string' '
1174 cat >.git/config <<-\EOF &&
1175 # broken section line
1179 test_must_fail git config --get section.key >actual 2>error &&
1180 grep " line 3 " error
1183 test_expect_success 'urlmatch' '
1184 cat >.git/config <<-\EOF &&
1187 [http "https://weak.example.com"]
1189 cookieFile = /tmp/cookie.txt
1192 echo true >expect &&
1193 git config --bool --get-urlmatch http.SSLverify https://good.example.com >actual &&
1194 test_cmp expect actual &&
1196 echo false >expect &&
1197 git config --bool --get-urlmatch http.sslverify https://weak.example.com >actual &&
1198 test_cmp expect actual &&
1201 echo http.cookiefile /tmp/cookie.txt &&
1202 echo http.sslverify false
1204 git config --get-urlmatch HTTP https://weak.example.com >actual &&
1205 test_cmp expect actual
1208 # good section hygiene
1209 test_expect_failure 'unsetting the last key in a section removes header' '
1210 cat >.git/config <<-\EOF &&
1211 # some generic comment on the configuration file itself
1212 # a comment specific to this "section" section.
1214 # some intervening lines
1215 # that should also be dropped
1218 # please be careful when you update the above variable
1221 cat >expect <<-\EOF &&
1222 # some generic comment on the configuration file itself
1225 git config --unset section.key &&
1226 test_cmp expect .git/config
1229 test_expect_failure 'adding a key into an empty section reuses header' '
1230 cat >.git/config <<-\EOF &&
1234 q_to_tab >expect <<-\EOF &&
1239 git config section.key value &&
1240 test_cmp expect .git/config
1243 test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
1244 chmod 0600 .git/config &&
1245 git config imap.pass Hunter2 &&
1247 "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
1248 git config --rename-section imap pop &&
1250 "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
1253 ! test_have_prereq MINGW ||
1254 HOME="$(pwd)" # convert to Windows path
1256 test_expect_success 'set up --show-origin tests' '
1257 INCLUDE_DIR="$HOME/include" &&
1258 mkdir -p "$INCLUDE_DIR" &&
1259 cat >"$INCLUDE_DIR"/absolute.include <<-\EOF &&
1263 cat >"$INCLUDE_DIR"/relative.include <<-\EOF &&
1267 cat >"$HOME"/.gitconfig <<-EOF &&
1272 path = "$INCLUDE_DIR/absolute.include"
1274 cat >.git/config <<-\EOF
1279 path = ../include/relative.include
1283 test_expect_success '--show-origin with --list' '
1284 cat >expect <<-EOF &&
1285 command line: alias.ci=commit
1286 command line: alias.co=checkout
1287 command line: alias.rb=rebase
1288 command line: alias.st=status
1289 command line: alias.br=branch
1290 command line: alias.pi=cherry-pick
1291 command line: alias.mt=mergetool
1292 file:$HOME/.gitconfig user.global=true
1293 file:$HOME/.gitconfig user.override=global
1294 file:$HOME/.gitconfig include.path=$INCLUDE_DIR/absolute.include
1295 file:$INCLUDE_DIR/absolute.include user.absolute=include
1296 file:.git/config user.local=true
1297 file:.git/config user.override=local
1298 file:.git/config include.path=../include/relative.include
1299 file:.git/../include/relative.include user.relative=include
1300 command line: user.cmdline=true
1302 git -c user.cmdline=true config --list --show-origin >output &&
1303 test_cmp expect output
1306 test_expect_success '--show-origin with --list --null' '
1307 cat >expect <<-EOF &&
1308 command line:Qalias.ci
1309 commitQcommand line:Qalias.co
1310 checkoutQcommand line:Qalias.rb
1311 rebaseQcommand line:Qalias.st
1312 statusQcommand line:Qalias.br
1313 branchQcommand line:Qalias.pi
1314 cherry-pickQcommand line:Qalias.mt
1315 mergetoolQfile:$HOME/.gitconfigQuser.global
1316 trueQfile:$HOME/.gitconfigQuser.override
1317 globalQfile:$HOME/.gitconfigQinclude.path
1318 $INCLUDE_DIR/absolute.includeQfile:$INCLUDE_DIR/absolute.includeQuser.absolute
1319 includeQfile:.git/configQuser.local
1320 trueQfile:.git/configQuser.override
1321 localQfile:.git/configQinclude.path
1322 ../include/relative.includeQfile:.git/../include/relative.includeQuser.relative
1323 includeQcommand line:Quser.cmdline
1326 git -c user.cmdline=true config --null --list --show-origin >output.raw &&
1327 nul_to_q <output.raw >output &&
1328 # The here-doc above adds a newline that the --null output would not
1329 # include. Add it here to make the two comparable.
1331 test_cmp expect output
1334 test_expect_success '--show-origin with single file' '
1335 cat >expect <<-\EOF &&
1336 file:.git/config user.local=true
1337 file:.git/config user.override=local
1338 file:.git/config include.path=../include/relative.include
1340 git config --local --list --show-origin >output &&
1341 test_cmp expect output
1344 test_expect_success '--show-origin with --get-regexp' '
1345 cat >expect <<-EOF &&
1346 file:$HOME/.gitconfig user.global true
1347 file:.git/config user.local true
1349 git config --show-origin --get-regexp "user\.[g|l].*" >output &&
1350 test_cmp expect output
1353 test_expect_success '--show-origin getting a single key' '
1354 cat >expect <<-\EOF &&
1355 file:.git/config local
1357 git config --show-origin user.override >output &&
1358 test_cmp expect output
1361 test_expect_success 'set up custom config file' '
1362 CUSTOM_CONFIG_FILE="file\" (dq) and spaces.conf" &&
1363 cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
1369 test_expect_success !MINGW '--show-origin escape special file name characters' '
1370 cat >expect <<-\EOF &&
1371 file:"file\" (dq) and spaces.conf" user.custom=true
1373 git config --file "$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1374 test_cmp expect output
1377 test_expect_success '--show-origin stdin' '
1378 cat >expect <<-\EOF &&
1379 standard input: user.custom=true
1381 git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
1382 test_cmp expect output
1385 test_expect_success '--show-origin stdin with file include' '
1386 cat >"$INCLUDE_DIR"/stdin.include <<-EOF &&
1390 cat >expect <<-EOF &&
1391 file:$INCLUDE_DIR/stdin.include include
1393 echo "[include]path=\"$INCLUDE_DIR\"/stdin.include" \
1394 | git config --show-origin --includes --file - user.stdin >output &&
1395 test_cmp expect output
1398 test_expect_success !MINGW '--show-origin blob' '
1399 cat >expect <<-\EOF &&
1400 blob:a9d9f9e555b5c6f07cbe09d3f06fe3df11e09c08 user.custom=true
1402 blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
1403 git config --blob=$blob --show-origin --list >output &&
1404 test_cmp expect output
1407 test_expect_success !MINGW '--show-origin blob ref' '
1408 cat >expect <<-\EOF &&
1409 blob:"master:file\" (dq) and spaces.conf" user.custom=true
1411 git add "$CUSTOM_CONFIG_FILE" &&
1412 git commit -m "new config file" &&
1413 git config --blob=master:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
1414 test_cmp expect output