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 test_expect_success 'configuration parsing with error' '
35 test_when_finished "rm -rf repo" &&
36 test_create_repo repo &&
37 cat >repo/.gitmodules <<-\EOF &&
44 test_must_fail test-submodule-config "" s 2>actual &&
45 test_i18ngrep "bad config" actual
49 cat >super/expect <<EOF
50 Submodule name: 'a' for path 'a'
51 Submodule name: 'a' for path 'b'
52 Submodule name: 'submodule' for path 'submodule'
53 Submodule name: 'submodule' for path 'submodule'
56 test_expect_success 'test parsing and lookup of submodule config by path' '
58 test-submodule-config \
64 test_cmp expect actual
68 test_expect_success 'test parsing and lookup of submodule config by name' '
70 test-submodule-config --name \
76 test_cmp expect actual
80 cat >super/expect_error <<EOF
81 Submodule name: 'a' for path 'b'
82 Submodule name: 'submodule' for path 'submodule'
85 test_expect_success 'error in one submodule config lets continue' '
87 cp .gitmodules .gitmodules.bak &&
88 echo " value = \"" >>.gitmodules &&
89 git add .gitmodules &&
90 mv .gitmodules.bak .gitmodules &&
91 git commit -m "add error" &&
92 test-submodule-config \
96 test_cmp expect_error actual
100 test_expect_success 'error message contains blob reference' '
102 sha1=$(git rev-parse HEAD) &&
103 test-submodule-config \
107 test_i18ngrep "submodule-blob $sha1:.gitmodules" actual_err >/dev/null
111 test_expect_success 'using different treeishs works' '
115 tree=$(git rev-parse HEAD^{tree}) &&
116 commit=$(git rev-parse HEAD^{commit}) &&
117 test-submodule-config $commit b >expect &&
118 test-submodule-config $tree b >actual.1 &&
119 test-submodule-config new_tag b >actual.2 &&
120 test_cmp expect actual.1 &&
121 test_cmp expect actual.2
125 test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
127 git config -f .gitmodules \
128 submodule.submodule.fetchrecursesubmodules blabla &&
129 git add .gitmodules &&
130 git config --unset -f .gitmodules \
131 submodule.submodule.fetchrecursesubmodules &&
132 git commit -m "add error in fetchrecursesubmodules" &&
133 test-submodule-config \
137 test_cmp expect_error actual &&
138 git reset --hard HEAD^