Update draft release notes to 1.8.3
[git/jnareb-git.git] / t / t5531-deep-submodule-push.sh
blob1947c28c6466d46c79c7b1b093488c1620324172
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 >junk &&
20 git add junk &&
21 git commit -m "Initial junk"
22 ) &&
23 git add gar/bage &&
24 git commit -m "Initial superproject"
28 test_expect_success push '
30 cd work &&
31 git push ../pub.git master
35 test_expect_success 'push if submodule has no remote' '
37 cd work/gar/bage &&
38 >junk2 &&
39 git add junk2 &&
40 git commit -m "Second junk"
41 ) &&
43 cd work &&
44 git add gar/bage &&
45 git commit -m "Second commit for gar/bage" &&
46 git push --recurse-submodules=check ../pub.git master
50 test_expect_success 'push fails if submodule commit not on remote' '
52 cd work/gar &&
53 git clone --bare bage ../../submodule.git &&
54 cd bage &&
55 git remote add origin ../../../submodule.git &&
56 git fetch &&
57 >junk3 &&
58 git add junk3 &&
59 git commit -m "Third junk"
60 ) &&
62 cd work &&
63 git add gar/bage &&
64 git commit -m "Third commit for gar/bage" &&
65 test_must_fail git push --recurse-submodules=check ../pub.git master
69 test_expect_success 'push succeeds after commit was pushed to remote' '
71 cd work/gar/bage &&
72 git push origin master
73 ) &&
75 cd work &&
76 git push --recurse-submodules=check ../pub.git master
80 test_expect_success 'push fails when commit on multiple branches if one branch has no remote' '
82 cd work/gar/bage &&
83 >junk4 &&
84 git add junk4 &&
85 git commit -m "Fourth junk"
86 ) &&
88 cd work &&
89 git branch branch2 &&
90 git add gar/bage &&
91 git commit -m "Fourth commit for gar/bage" &&
92 git checkout branch2 &&
94 cd gar/bage &&
95 git checkout HEAD~1
96 ) &&
97 >junk1 &&
98 git add junk1 &&
99 git commit -m "First junk" &&
100 test_must_fail git push --recurse-submodules=check ../pub.git
104 test_expect_success 'push succeeds if submodule has no remote and is on the first superproject commit' '
105 git init --bare a
106 git clone a a1 &&
108 cd a1 &&
109 git init b
111 cd b &&
112 >junk &&
113 git add junk &&
114 git commit -m "initial"
115 ) &&
116 git add b &&
117 git commit -m "added submodule" &&
118 git push --recurse-submodule=check origin master
122 test_expect_success 'push unpushed submodules when not needed' '
124 cd work &&
126 cd gar/bage &&
127 git checkout master &&
128 >junk5 &&
129 git add junk5 &&
130 git commit -m "Fifth junk" &&
131 git push &&
132 git rev-parse origin/master >../../../expected
133 ) &&
134 git checkout master &&
135 git add gar/bage &&
136 git commit -m "Fifth commit for gar/bage" &&
137 git push --recurse-submodules=on-demand ../pub.git master
138 ) &&
140 cd submodule.git &&
141 git rev-parse master >../actual
142 ) &&
143 test_cmp expected actual
146 test_expect_success 'push unpushed submodules when not needed 2' '
148 cd submodule.git &&
149 git rev-parse master >../expected
150 ) &&
152 cd work &&
154 cd gar/bage &&
155 >junk6 &&
156 git add junk6 &&
157 git commit -m "Sixth junk"
158 ) &&
159 >junk2 &&
160 git add junk2 &&
161 git commit -m "Second junk for work" &&
162 git push --recurse-submodules=on-demand ../pub.git master
163 ) &&
165 cd submodule.git &&
166 git rev-parse master >../actual
167 ) &&
168 test_cmp expected actual
171 test_expect_success 'push unpushed submodules recursively' '
173 cd work &&
175 cd gar/bage &&
176 git checkout master &&
177 > junk7 &&
178 git add junk7 &&
179 git commit -m "Seventh junk" &&
180 git rev-parse master >../../../expected
181 ) &&
182 git checkout master &&
183 git add gar/bage &&
184 git commit -m "Seventh commit for gar/bage" &&
185 git push --recurse-submodules=on-demand ../pub.git master
186 ) &&
188 cd submodule.git &&
189 git rev-parse master >../actual
190 ) &&
191 test_cmp expected actual
194 test_expect_success 'push unpushable submodule recursively fails' '
196 cd work &&
198 cd gar/bage &&
199 git rev-parse origin/master >../../../expected &&
200 git checkout master~0 &&
201 > junk8 &&
202 git add junk8 &&
203 git commit -m "Eighth junk"
204 ) &&
205 git add gar/bage &&
206 git commit -m "Eighth commit for gar/bage" &&
207 test_must_fail git push --recurse-submodules=on-demand ../pub.git master
208 ) &&
210 cd submodule.git &&
211 git rev-parse master >../actual
212 ) &&
213 test_cmp expected actual
216 test_done