Merge branch 'jk/stash-list-p' into jch
[git/jrn.git] / t / t7411-submodule-config.sh
blob1ba0d64626b60ccb02217f863d33cfa7efec755a
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 of submodule config' '
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 cat >super/expect_error <<EOF
54 Submodule name: 'a' for path 'b'
55 Submodule name: 'submodule' for path 'submodule'
56 EOF
58 test_expect_success 'error in one submodule config lets continue' '
59 (cd super &&
60 cp .gitmodules .gitmodules.bak &&
61 echo " value = \"" >>.gitmodules &&
62 git add .gitmodules &&
63 mv .gitmodules.bak .gitmodules &&
64 git commit -m "add error" &&
65 test-submodule-config \
66 HEAD b \
67 HEAD submodule \
68 >actual &&
69 test_cmp expect_error actual
73 cat >super/expect_url <<EOF
74 Submodule url: 'git@somewhere.else.net:a.git' for path 'b'
75 Submodule url: 'git@somewhere.else.net:submodule.git' for path 'submodule'
76 EOF
78 cat >super/expect_local_path <<EOF
79 Submodule name: 'a' for path 'c'
80 Submodule name: 'submodule' for path 'submodule'
81 EOF
83 test_expect_success 'reading of local configuration' '
84 (cd super &&
85 old_a=$(git config submodule.a.url) &&
86 old_submodule=$(git config submodule.submodule.url) &&
87 git config submodule.a.url git@somewhere.else.net:a.git &&
88 git config submodule.submodule.url git@somewhere.else.net:submodule.git &&
89 test-submodule-config --url \
90 "" b \
91 "" submodule \
92 >actual &&
93 test_cmp expect_url actual &&
94 git config submodule.a.path c &&
95 test-submodule-config \
96 "" c \
97 "" submodule \
98 >actual &&
99 test_cmp expect_local_path actual &&
100 git config submodule.a.url $old_a &&
101 git config submodule.submodule.url $old_submodule &&
102 git config --unset submodule.a.path c
106 cat >super/expect_fetchrecurse_die.err <<EOF
107 fatal: bad submodule.submodule.fetchrecursesubmodules argument: blabla
110 test_expect_success 'local error in fetchrecursesubmodule dies early' '
111 (cd super &&
112 git config submodule.submodule.fetchrecursesubmodules blabla &&
113 test_must_fail test-submodule-config \
114 "" b \
115 "" submodule \
116 >actual.out 2>actual.err &&
117 touch expect_fetchrecurse_die.out &&
118 test_cmp expect_fetchrecurse_die.out actual.out &&
119 test_cmp expect_fetchrecurse_die.err actual.err &&
120 git config --unset submodule.submodule.fetchrecursesubmodules
124 test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
125 (cd super &&
126 git config -f .gitmodules \
127 submodule.submodule.fetchrecursesubmodules blabla &&
128 git add .gitmodules &&
129 git config --unset -f .gitmodules \
130 submodule.submodule.fetchrecursesubmodules &&
131 git commit -m "add error in fetchrecursesubmodules" &&
132 test-submodule-config \
133 HEAD b \
134 HEAD submodule \
135 >actual &&
136 test_cmp expect_error actual &&
137 git reset --hard HEAD^
141 test_done