remote-curl: pass ref SHA-1 to fetch-pack as well
[git.git] / t / t5531-deep-submodule-push.sh
blob8c16e045a0c585957a0be4e31b5628d1d5b6cb23
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 mkdir -p gar/bage &&
17 cd gar/bage &&
18 git init &&
19 git config push.default matching &&
20 >junk &&
21 git add junk &&
22 git commit -m "Initial junk"
23 ) &&
24 git add gar/bage &&
25 git commit -m "Initial superproject"
29 test_expect_success push '
31 cd work &&
32 git push ../pub.git master
36 test_expect_success 'push if submodule has no remote' '
38 cd work/gar/bage &&
39 >junk2 &&
40 git add junk2 &&
41 git commit -m "Second junk"
42 ) &&
44 cd work &&
45 git add gar/bage &&
46 git commit -m "Second commit for gar/bage" &&
47 git push --recurse-submodules=check ../pub.git master
51 test_expect_success 'push fails if submodule commit not on remote' '
53 cd work/gar &&
54 git clone --bare bage ../../submodule.git &&
55 cd bage &&
56 git remote add origin ../../../submodule.git &&
57 git fetch &&
58 >junk3 &&
59 git add junk3 &&
60 git commit -m "Third junk"
61 ) &&
63 cd work &&
64 git add gar/bage &&
65 git commit -m "Third commit for gar/bage" &&
66 test_must_fail git push --recurse-submodules=check ../pub.git master
70 test_expect_success 'push succeeds after commit was pushed to remote' '
72 cd work/gar/bage &&
73 git push origin master
74 ) &&
76 cd work &&
77 git push --recurse-submodules=check ../pub.git master
81 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
83 cd work/gar/bage &&
84 >junk4 &&
85 git add junk4 &&
86 git commit -m "Fourth junk"
87 ) &&
89 cd work &&
90 git branch branch2 &&
91 git add gar/bage &&
92 git commit -m "Fourth commit for gar/bage" &&
93 git checkout branch2 &&
95 cd gar/bage &&
96 git checkout HEAD~1
97 ) &&
98 >junk1 &&
99 git add junk1 &&
100 git commit -m "First junk" &&
101 test_must_fail git push --recurse-submodules=check ../pub.git
105 test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
106 git init --bare a
107 git clone a a1 &&
109 cd a1 &&
110 git init b
112 cd b &&
113 >junk &&
114 git add junk &&
115 git commit -m "initial"
116 ) &&
117 git add b &&
118 git commit -m "added submodule" &&
119 git push --recurse-submodule=check origin master
123 test_expect_success 'push unpushed submodules when not needed' '
125 cd work &&
127 cd gar/bage &&
128 git checkout master &&
129 >junk5 &&
130 git add junk5 &&
131 git commit -m "Fifth junk" &&
132 git push &&
133 git rev-parse origin/master >../../../expected
134 ) &&
135 git checkout master &&
136 git add gar/bage &&
137 git commit -m "Fifth commit for gar/bage" &&
138 git push --recurse-submodules=on-demand ../pub.git master
139 ) &&
141 cd submodule.git &&
142 git rev-parse master >../actual
143 ) &&
144 test_cmp expected actual
147 test_expect_success 'push unpushed submodules when not needed 2' '
149 cd submodule.git &&
150 git rev-parse master >../expected
151 ) &&
153 cd work &&
155 cd gar/bage &&
156 >junk6 &&
157 git add junk6 &&
158 git commit -m "Sixth junk"
159 ) &&
160 >junk2 &&
161 git add junk2 &&
162 git commit -m "Second junk for work" &&
163 git push --recurse-submodules=on-demand ../pub.git master
164 ) &&
166 cd submodule.git &&
167 git rev-parse master >../actual
168 ) &&
169 test_cmp expected actual
172 test_expect_success 'push unpushed submodules recursively' '
174 cd work &&
176 cd gar/bage &&
177 git checkout master &&
178 > junk7 &&
179 git add junk7 &&
180 git commit -m "Seventh junk" &&
181 git rev-parse master >../../../expected
182 ) &&
183 git checkout master &&
184 git add gar/bage &&
185 git commit -m "Seventh commit for gar/bage" &&
186 git push --recurse-submodules=on-demand ../pub.git master
187 ) &&
189 cd submodule.git &&
190 git rev-parse master >../actual
191 ) &&
192 test_cmp expected actual
195 test_expect_success 'push unpushable submodule recursively fails' '
197 cd work &&
199 cd gar/bage &&
200 git rev-parse origin/master >../../../expected &&
201 git checkout master~0 &&
202 > junk8 &&
203 git add junk8 &&
204 git commit -m "Eighth junk"
205 ) &&
206 git add gar/bage &&
207 git commit -m "Eighth commit for gar/bage" &&
208 test_must_fail git push --recurse-submodules=on-demand ../pub.git master
209 ) &&
211 cd submodule.git &&
212 git rev-parse master >../actual
213 ) &&
214 test_cmp expected actual
217 test_done