bisect: sanity check on terms
[git/debian.git] / t / t5531-deep-submodule-push.sh
blob6507487c1a43bb407ed7598551364c4eb5a60cc6
1 #!/bin/sh
3 test_description='unpack-objects'
5 . ./test-lib.sh
7 test_expect_success setup '
8 mkdir pub.git &&
9 GIT_DIR=pub.git git init --bare &&
10 GIT_DIR=pub.git git config receive.fsckobjects true &&
11 mkdir work &&
13 cd work &&
14 git init &&
15 git config push.default matching &&
16 mkdir -p gar/bage &&
18 cd gar/bage &&
19 git init &&
20 git config push.default matching &&
21 >junk &&
22 git add junk &&
23 git commit -m "Initial junk"
24 ) &&
25 git add gar/bage &&
26 git commit -m "Initial superproject"
30 test_expect_success push '
32 cd work &&
33 git push ../pub.git master
37 test_expect_success 'push if submodule has no remote' '
39 cd work/gar/bage &&
40 >junk2 &&
41 git add junk2 &&
42 git commit -m "Second junk"
43 ) &&
45 cd work &&
46 git add gar/bage &&
47 git commit -m "Second commit for gar/bage" &&
48 git push --recurse-submodules=check ../pub.git master
52 test_expect_success 'push fails if submodule commit not on remote' '
54 cd work/gar &&
55 git clone --bare bage ../../submodule.git &&
56 cd bage &&
57 git remote add origin ../../../submodule.git &&
58 git fetch &&
59 >junk3 &&
60 git add junk3 &&
61 git commit -m "Third junk"
62 ) &&
64 cd work &&
65 git add gar/bage &&
66 git commit -m "Third commit for gar/bage" &&
67 test_must_fail git push --recurse-submodules=check ../pub.git master
71 test_expect_success 'push succeeds after commit was pushed to remote' '
73 cd work/gar/bage &&
74 git push origin master
75 ) &&
77 cd work &&
78 git push --recurse-submodules=check ../pub.git master
82 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
84 cd work/gar/bage &&
85 >junk4 &&
86 git add junk4 &&
87 git commit -m "Fourth junk"
88 ) &&
90 cd work &&
91 git branch branch2 &&
92 git add gar/bage &&
93 git commit -m "Fourth commit for gar/bage" &&
94 git checkout branch2 &&
96 cd gar/bage &&
97 git checkout HEAD~1
98 ) &&
99 >junk1 &&
100 git add junk1 &&
101 git commit -m "First junk" &&
102 test_must_fail git push --recurse-submodules=check ../pub.git
106 test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
107 git init --bare a &&
108 git clone a a1 &&
110 cd a1 &&
111 git init b
113 cd b &&
114 >junk &&
115 git add junk &&
116 git commit -m "initial"
117 ) &&
118 git add b &&
119 git commit -m "added submodule" &&
120 git push --recurse-submodule=check origin master
124 test_expect_success 'push unpushed submodules when not needed' '
126 cd work &&
128 cd gar/bage &&
129 git checkout master &&
130 >junk5 &&
131 git add junk5 &&
132 git commit -m "Fifth junk" &&
133 git push &&
134 git rev-parse origin/master >../../../expected
135 ) &&
136 git checkout master &&
137 git add gar/bage &&
138 git commit -m "Fifth commit for gar/bage" &&
139 git push --recurse-submodules=on-demand ../pub.git master
140 ) &&
142 cd submodule.git &&
143 git rev-parse master >../actual
144 ) &&
145 test_cmp expected actual
148 test_expect_success 'push unpushed submodules when not needed 2' '
150 cd submodule.git &&
151 git rev-parse master >../expected
152 ) &&
154 cd work &&
156 cd gar/bage &&
157 >junk6 &&
158 git add junk6 &&
159 git commit -m "Sixth junk"
160 ) &&
161 >junk2 &&
162 git add junk2 &&
163 git commit -m "Second junk for work" &&
164 git push --recurse-submodules=on-demand ../pub.git master
165 ) &&
167 cd submodule.git &&
168 git rev-parse master >../actual
169 ) &&
170 test_cmp expected actual
173 test_expect_success 'push unpushed submodules recursively' '
175 cd work &&
177 cd gar/bage &&
178 git checkout master &&
179 > junk7 &&
180 git add junk7 &&
181 git commit -m "Seventh junk" &&
182 git rev-parse master >../../../expected
183 ) &&
184 git checkout master &&
185 git add gar/bage &&
186 git commit -m "Seventh commit for gar/bage" &&
187 git push --recurse-submodules=on-demand ../pub.git master
188 ) &&
190 cd submodule.git &&
191 git rev-parse master >../actual
192 ) &&
193 test_cmp expected actual
196 test_expect_success 'push unpushable submodule recursively fails' '
198 cd work &&
200 cd gar/bage &&
201 git rev-parse origin/master >../../../expected &&
202 git checkout master~0 &&
203 > junk8 &&
204 git add junk8 &&
205 git commit -m "Eighth junk"
206 ) &&
207 git add gar/bage &&
208 git commit -m "Eighth commit for gar/bage" &&
209 test_must_fail git push --recurse-submodules=on-demand ../pub.git master
210 ) &&
212 cd submodule.git &&
213 git rev-parse master >../actual
214 ) &&
215 test_cmp expected actual
218 test_done