MSVC: require pton and ntop emulation
[git/dscho.git] / t / t1305-config-include.sh
blob0a27ec48d0695f6a3d475d8b1f116e1cabbdff47
1 #!/bin/sh
3 test_description='test config file include directives'
4 . ./test-lib.sh
6 test_expect_success 'include file by absolute path' '
7 echo "[test]one = 1" >one &&
8 echo "[include]path = \"$PWD/one\"" >.gitconfig &&
9 echo 1 >expect &&
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 &&
17 echo 1 >expect &&
18 git config test.one >actual &&
19 test_cmp expect actual
22 test_expect_success 'chained relative paths' '
23 mkdir subdir &&
24 echo "[test]three = 3" >subdir/three &&
25 echo "[include]path = three" >subdir/two &&
26 echo "[include]path = subdir/two" >.gitconfig &&
27 echo 3 >expect &&
28 git config test.three >actual &&
29 test_cmp expect actual
32 test_expect_success 'include options can still be examined' '
33 echo "[test]one = 1" >one &&
34 echo "[include]path = one" >.gitconfig &&
35 echo one >expect &&
36 git config include.path >actual &&
37 test_cmp expect actual
40 test_expect_success 'listing includes option and expansion' '
41 echo "[test]one = 1" >one &&
42 echo "[include]path = one" >.gitconfig &&
43 cat >expect <<-\EOF &&
44 include.path=one
45 test.one=1
46 EOF
47 git config --list >actual.full &&
48 grep -v ^core actual.full >actual &&
49 test_cmp expect actual
52 test_expect_success 'single file lookup does not expand includes by default' '
53 echo "[test]one = 1" >one &&
54 echo "[include]path = one" >.gitconfig &&
55 test_must_fail git config -f .gitconfig test.one &&
56 test_must_fail git config --global test.one &&
57 echo 1 >expect &&
58 git config --includes -f .gitconfig test.one >actual &&
59 test_cmp expect actual
62 test_expect_success 'writing config file does not expand includes' '
63 echo "[test]one = 1" >one &&
64 echo "[include]path = one" >.gitconfig &&
65 git config test.two 2 &&
66 echo 2 >expect &&
67 git config --no-includes test.two >actual &&
68 test_cmp expect actual &&
69 test_must_fail git config --no-includes test.one
72 test_expect_success 'config modification does not affect includes' '
73 echo "[test]one = 1" >one &&
74 echo "[include]path = one" >.gitconfig &&
75 git config test.one 2 &&
76 echo 1 >expect &&
77 git config -f one test.one >actual &&
78 test_cmp expect actual &&
79 cat >expect <<-\EOF &&
82 EOF
83 git config --get-all test.one >actual &&
84 test_cmp expect actual
87 test_expect_success 'missing include files are ignored' '
88 cat >.gitconfig <<-\EOF &&
89 [include]path = foo
90 [test]value = yes
91 EOF
92 echo yes >expect &&
93 git config test.value >actual &&
94 test_cmp expect actual
97 test_expect_success 'absolute includes from command line work' '
98 echo "[test]one = 1" >one &&
99 echo 1 >expect &&
100 git -c include.path="$PWD/one" config test.one >actual &&
101 test_cmp expect actual
104 test_expect_success 'relative includes from command line fail' '
105 echo "[test]one = 1" >one &&
106 test_must_fail git -c include.path=one config test.one
109 test_expect_success 'include cycles are detected' '
110 cat >.gitconfig <<-\EOF &&
111 [test]value = gitconfig
112 [include]path = cycle
114 cat >cycle <<-\EOF &&
115 [test]value = cycle
116 [include]path = .gitconfig
118 cat >expect <<-\EOF &&
119 gitconfig
120 cycle
122 test_must_fail git config --get-all test.value 2>stderr &&
123 grep "exceeded maximum include depth" stderr
126 test_done