Merge branch 'jk/avoid-unbounded-alloca'
[git/git-svn.git] / t / t7411-submodule-config.sh
blobfc97c3314e2d89e11b4a846457f5e183f4fc42c0
1 #!/bin/sh
3 # Copyright (c) 2014 Heiko Voigt
6 test_description='Test submodules config cache infrastructure
8 This test verifies that parsing .gitmodules configurations directly
9 from the database and from the worktree works.
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
15 test_expect_success 'submodule config cache setup' '
16 mkdir submodule &&
17 (cd submodule &&
18 git init &&
19 echo a >a &&
20 git add . &&
21 git commit -ma
22 ) &&
23 mkdir super &&
24 (cd super &&
25 git init &&
26 git submodule add ../submodule &&
27 git submodule add ../submodule a &&
28 git commit -m "add as submodule and as a" &&
29 git mv a b &&
30 git commit -m "move a to b"
34 cat >super/expect <<EOF
35 Submodule name: 'a' for path 'a'
36 Submodule name: 'a' for path 'b'
37 Submodule name: 'submodule' for path 'submodule'
38 Submodule name: 'submodule' for path 'submodule'
39 EOF
41 test_expect_success 'test parsing and lookup of submodule config by path' '
42 (cd super &&
43 test-submodule-config \
44 HEAD^ a \
45 HEAD b \
46 HEAD^ submodule \
47 HEAD submodule \
48 >actual &&
49 test_cmp expect actual
53 test_expect_success 'test parsing and lookup of submodule config by name' '
54 (cd super &&
55 test-submodule-config --name \
56 HEAD^ a \
57 HEAD a \
58 HEAD^ submodule \
59 HEAD submodule \
60 >actual &&
61 test_cmp expect actual
65 cat >super/expect_error <<EOF
66 Submodule name: 'a' for path 'b'
67 Submodule name: 'submodule' for path 'submodule'
68 EOF
70 test_expect_success 'error in one submodule config lets continue' '
71 (cd super &&
72 cp .gitmodules .gitmodules.bak &&
73 echo " value = \"" >>.gitmodules &&
74 git add .gitmodules &&
75 mv .gitmodules.bak .gitmodules &&
76 git commit -m "add error" &&
77 test-submodule-config \
78 HEAD b \
79 HEAD submodule \
80 >actual &&
81 test_cmp expect_error actual
85 cat >super/expect_url <<EOF
86 Submodule url: 'git@somewhere.else.net:a.git' for path 'b'
87 Submodule url: 'git@somewhere.else.net:submodule.git' for path 'submodule'
88 EOF
90 cat >super/expect_local_path <<EOF
91 Submodule name: 'a' for path 'c'
92 Submodule name: 'submodule' for path 'submodule'
93 EOF
95 test_expect_success 'reading of local configuration' '
96 (cd super &&
97 old_a=$(git config submodule.a.url) &&
98 old_submodule=$(git config submodule.submodule.url) &&
99 git config submodule.a.url git@somewhere.else.net:a.git &&
100 git config submodule.submodule.url git@somewhere.else.net:submodule.git &&
101 test-submodule-config --url \
102 "" b \
103 "" submodule \
104 >actual &&
105 test_cmp expect_url actual &&
106 git config submodule.a.path c &&
107 test-submodule-config \
108 "" c \
109 "" submodule \
110 >actual &&
111 test_cmp expect_local_path actual &&
112 git config submodule.a.url $old_a &&
113 git config submodule.submodule.url $old_submodule &&
114 git config --unset submodule.a.path c
118 cat >super/expect_fetchrecurse_die.err <<EOF
119 fatal: bad submodule.submodule.fetchrecursesubmodules argument: blabla
122 test_expect_success 'local error in fetchrecursesubmodule dies early' '
123 (cd super &&
124 git config submodule.submodule.fetchrecursesubmodules blabla &&
125 test_must_fail test-submodule-config \
126 "" b \
127 "" submodule \
128 >actual.out 2>actual.err &&
129 touch expect_fetchrecurse_die.out &&
130 test_cmp expect_fetchrecurse_die.out actual.out &&
131 test_cmp expect_fetchrecurse_die.err actual.err &&
132 git config --unset submodule.submodule.fetchrecursesubmodules
136 test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
137 (cd super &&
138 git config -f .gitmodules \
139 submodule.submodule.fetchrecursesubmodules blabla &&
140 git add .gitmodules &&
141 git config --unset -f .gitmodules \
142 submodule.submodule.fetchrecursesubmodules &&
143 git commit -m "add error in fetchrecursesubmodules" &&
144 test-submodule-config \
145 HEAD b \
146 HEAD submodule \
147 >actual &&
148 test_cmp expect_error actual &&
149 git reset --hard HEAD^
153 test_done