@@ -184,11 +184,12 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat
184184 test_config -C "$d" http.receivepack true &&
185185 up="$HTTPD_URL"/smart/atomic-branches.git &&
186186
187- # Tell "$up" about two branches for now
187+ # Tell "$up" about three branches for now
188188 test_commit atomic1 &&
189189 test_commit atomic2 &&
190190 git branch collateral &&
191- git push "$up" master collateral &&
191+ git branch other &&
192+ git push "$up" master collateral other &&
192193
193194 # collateral is a valid push, but should be failed by atomic push
194195 git checkout collateral &&
@@ -226,6 +227,41 @@ test_expect_success 'push --atomic also prevents branch creation, reports collat
226227 grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output
227228'
228229
230+ test_expect_success ' push --atomic fails on server-side errors' '
231+ # Use previously set up repository
232+ d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git &&
233+ test_config -C "$d" http.receivepack true &&
234+ up="$HTTPD_URL"/smart/atomic-branches.git &&
235+
236+ # break ref updates for other on the remote site
237+ mkdir "$d/refs/heads/other.lock" &&
238+
239+ # add the new commit to other
240+ git branch -f other collateral &&
241+
242+ # --atomic should cause entire push to be rejected
243+ test_must_fail git push --atomic "$up" atomic other 2>output &&
244+
245+ # the new branch should not have been created upstream
246+ test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
247+
248+ # upstream should still reflect atomic2, the last thing we pushed
249+ # successfully
250+ git rev-parse atomic2 >expected &&
251+ # ...to other.
252+ git -C "$d" rev-parse refs/heads/other >actual &&
253+ test_cmp expected actual &&
254+
255+ # the new branch should not have been created upstream
256+ test_must_fail git -C "$d" show-ref --verify refs/heads/atomic &&
257+
258+ # the failed refs should be indicated to the user
259+ grep "^ ! .*rejected.* other -> other .*atomic transaction failed" output &&
260+
261+ # the collateral failure refs should be indicated to the user
262+ grep "^ ! .*rejected.* atomic -> atomic .*atomic transaction failed" output
263+ '
264+
229265test_expect_success ' push --all can push to empty repo' '
230266 d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&
231267 git init --bare "$d" &&
0 commit comments