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.
15 test_expect_success
'submodule config cache setup' '
26 git submodule add ../submodule &&
27 git submodule add ../submodule a &&
28 git commit -m "add as submodule and as a" &&
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'
41 test_expect_success
'test parsing and lookup of submodule config by path' '
43 test-submodule-config \
49 test_cmp expect actual
53 test_expect_success
'test parsing and lookup of submodule config by name' '
55 test-submodule-config --name \
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'
70 test_expect_success
'error in one submodule config lets continue' '
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 \
81 test_cmp expect_error actual
85 test_expect_success
'error message contains blob reference' '
87 sha1=$(git rev-parse HEAD) &&
88 test-submodule-config \
92 test_i18ngrep "submodule-blob $sha1:.gitmodules" actual_err >/dev/null
96 test_expect_success
'using different treeishs works' '
100 tree=$(git rev-parse HEAD^{tree}) &&
101 commit=$(git rev-parse HEAD^{commit}) &&
102 test-submodule-config $commit b >expect &&
103 test-submodule-config $tree b >actual.1 &&
104 test-submodule-config new_tag b >actual.2 &&
105 test_cmp expect actual.1 &&
106 test_cmp expect actual.2
110 cat >super
/expect_url
<<EOF
111 Submodule url: 'git@somewhere.else.net:a.git' for path 'b'
112 Submodule url: 'git@somewhere.else.net:submodule.git' for path 'submodule'
115 cat >super
/expect_local_path
<<EOF
116 Submodule name: 'a' for path 'c'
117 Submodule name: 'submodule' for path 'submodule'
120 test_expect_success
'reading of local configuration' '
122 old_a=$(git config submodule.a.url) &&
123 old_submodule=$(git config submodule.submodule.url) &&
124 git config submodule.a.url git@somewhere.else.net:a.git &&
125 git config submodule.submodule.url git@somewhere.else.net:submodule.git &&
126 test-submodule-config --url \
130 test_cmp expect_url actual &&
131 git config submodule.a.path c &&
132 test-submodule-config \
136 test_cmp expect_local_path actual &&
137 git config submodule.a.url $old_a &&
138 git config submodule.submodule.url $old_submodule &&
139 git config --unset submodule.a.path c
143 cat >super
/expect_fetchrecurse_die.err
<<EOF
144 fatal: bad submodule.submodule.fetchrecursesubmodules argument: blabla
147 test_expect_success
'local error in fetchrecursesubmodule dies early' '
149 git config submodule.submodule.fetchrecursesubmodules blabla &&
150 test_must_fail test-submodule-config \
153 >actual.out 2>actual.err &&
154 touch expect_fetchrecurse_die.out &&
155 test_cmp expect_fetchrecurse_die.out actual.out &&
156 test_cmp expect_fetchrecurse_die.err actual.err &&
157 git config --unset submodule.submodule.fetchrecursesubmodules
161 test_expect_success
'error in history in fetchrecursesubmodule lets continue' '
163 git config -f .gitmodules \
164 submodule.submodule.fetchrecursesubmodules blabla &&
165 git add .gitmodules &&
166 git config --unset -f .gitmodules \
167 submodule.submodule.fetchrecursesubmodules &&
168 git commit -m "add error in fetchrecursesubmodules" &&
169 test-submodule-config \
173 test_cmp expect_error actual &&
174 git reset --hard HEAD^