3 test_description
='test config file include directives'
6 test_expect_success
'include file by absolute path' '
7 echo "[test]one = 1" >one &&
8 echo "[include]path = \"$(pwd)/one\"" >.gitconfig &&
10 git config test.one >actual &&
11 test_cmp expect actual
14 test_expect_success
'include file by relative path' '
15 echo "[test]one = 1" >one &&
16 echo "[include]path = one" >.gitconfig &&
18 git config test.one >actual &&
19 test_cmp expect actual
22 test_expect_success
'chained relative paths' '
24 echo "[test]three = 3" >subdir/three &&
25 echo "[include]path = three" >subdir/two &&
26 echo "[include]path = subdir/two" >.gitconfig &&
28 git config test.three >actual &&
29 test_cmp expect actual
32 test_expect_success
'include paths get tilde-expansion' '
33 echo "[test]one = 1" >one &&
34 echo "[include]path = ~/one" >.gitconfig &&
36 git config test.one >actual &&
37 test_cmp expect actual
40 test_expect_success
'include options can still be examined' '
41 echo "[test]one = 1" >one &&
42 echo "[include]path = one" >.gitconfig &&
44 git config include.path >actual &&
45 test_cmp expect actual
48 test_expect_success
'listing includes option and expansion' '
49 echo "[test]one = 1" >one &&
50 echo "[include]path = one" >.gitconfig &&
51 cat >expect <<-\EOF &&
55 git config --list >actual.full &&
56 grep -v ^core actual.full >actual &&
57 test_cmp expect actual
60 test_expect_success
'single file lookup does not expand includes by default' '
61 echo "[test]one = 1" >one &&
62 echo "[include]path = one" >.gitconfig &&
63 test_must_fail git config -f .gitconfig test.one &&
64 test_must_fail git config --global test.one &&
66 git config --includes -f .gitconfig test.one >actual &&
67 test_cmp expect actual
70 test_expect_success
'single file list does not expand includes by default' '
71 echo "[test]one = 1" >one &&
72 echo "[include]path = one" >.gitconfig &&
73 echo "include.path=one" >expect &&
74 git config -f .gitconfig --list >actual &&
75 test_cmp expect actual
78 test_expect_success
'writing config file does not expand includes' '
79 echo "[test]one = 1" >one &&
80 echo "[include]path = one" >.gitconfig &&
81 git config test.two 2 &&
83 git config --no-includes test.two >actual &&
84 test_cmp expect actual &&
85 test_must_fail git config --no-includes test.one
88 test_expect_success
'config modification does not affect includes' '
89 echo "[test]one = 1" >one &&
90 echo "[include]path = one" >.gitconfig &&
91 git config test.one 2 &&
93 git config -f one test.one >actual &&
94 test_cmp expect actual &&
95 cat >expect <<-\EOF &&
99 git config --get-all test.one >actual &&
100 test_cmp expect actual
103 test_expect_success
'missing include files are ignored' '
104 cat >.gitconfig <<-\EOF &&
109 git config test.value >actual &&
110 test_cmp expect actual
113 test_expect_success
'absolute includes from command line work' '
114 echo "[test]one = 1" >one &&
116 git -c include.path="$PWD/one" config test.one >actual &&
117 test_cmp expect actual
120 test_expect_success
'relative includes from command line fail' '
121 echo "[test]one = 1" >one &&
122 test_must_fail git -c include.path=one config test.one
125 test_expect_success
'include cycles are detected' '
126 cat >.gitconfig <<-\EOF &&
127 [test]value = gitconfig
128 [include]path = cycle
130 cat >cycle <<-\EOF &&
132 [include]path = .gitconfig
134 cat >expect <<-\EOF &&
138 test_must_fail git config --get-all test.value 2>stderr &&
139 grep "exceeded maximum include depth" stderr