@@ -105,7 +105,6 @@ check_push_result () {
105105}
106106
107107test_expect_success setup '
108-
109108 >path1 &&
110109 git add path1 &&
111110 test_tick &&
@@ -117,7 +116,6 @@ test_expect_success setup '
117116 test_tick &&
118117 git commit -a -m second &&
119118 the_commit=$(git show-ref -s --verify refs/heads/main)
120-
121119'
122120
123121for cmd in push fetch
@@ -322,104 +320,82 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf
322320'
323321
324322test_expect_success ' push with matching heads' '
325-
326323 mk_test testrepo heads/main &&
327324 git push testrepo : &&
328325 check_push_result testrepo $the_commit heads/main
329-
330326'
331327
332328test_expect_success ' push with matching heads on the command line' '
333-
334329 mk_test testrepo heads/main &&
335330 git push testrepo : &&
336331 check_push_result testrepo $the_commit heads/main
337-
338332'
339333
340334test_expect_success ' failed (non-fast-forward) push with matching heads' '
341-
342335 mk_test testrepo heads/main &&
343336 git push testrepo : &&
344337 git commit --amend -massaged &&
345338 test_must_fail git push testrepo &&
346339 check_push_result testrepo $the_commit heads/main &&
347340 git reset --hard $the_commit
348-
349341'
350342
351343test_expect_success ' push --force with matching heads' '
352-
353344 mk_test testrepo heads/main &&
354345 git push testrepo : &&
355346 git commit --amend -massaged &&
356347 git push --force testrepo : &&
357348 ! check_push_result testrepo $the_commit heads/main &&
358349 git reset --hard $the_commit
359-
360350'
361351
362352test_expect_success ' push with matching heads and forced update' '
363-
364353 mk_test testrepo heads/main &&
365354 git push testrepo : &&
366355 git commit --amend -massaged &&
367356 git push testrepo +: &&
368357 ! check_push_result testrepo $the_commit heads/main &&
369358 git reset --hard $the_commit
370-
371359'
372360
373361test_expect_success ' push with no ambiguity (1)' '
374-
375362 mk_test testrepo heads/main &&
376363 git push testrepo main:main &&
377364 check_push_result testrepo $the_commit heads/main
378-
379365'
380366
381367test_expect_success ' push with no ambiguity (2)' '
382-
383368 mk_test testrepo remotes/origin/main &&
384369 git push testrepo main:origin/main &&
385370 check_push_result testrepo $the_commit remotes/origin/main
386-
387371'
388372
389373test_expect_success ' push with colon-less refspec, no ambiguity' '
390-
391374 mk_test testrepo heads/main heads/t/main &&
392375 git branch -f t/main main &&
393376 git push testrepo main &&
394377 check_push_result testrepo $the_commit heads/main &&
395378 check_push_result testrepo $the_first_commit heads/t/main
396-
397379'
398380
399381test_expect_success ' push with weak ambiguity (1)' '
400-
401382 mk_test testrepo heads/main remotes/origin/main &&
402383 git push testrepo main:main &&
403384 check_push_result testrepo $the_commit heads/main &&
404385 check_push_result testrepo $the_first_commit remotes/origin/main
405-
406386'
407387
408388test_expect_success ' push with weak ambiguity (2)' '
409-
410389 mk_test testrepo heads/main remotes/origin/main remotes/another/main &&
411390 git push testrepo main:main &&
412391 check_push_result testrepo $the_commit heads/main &&
413392 check_push_result testrepo $the_first_commit remotes/origin/main remotes/another/main
414-
415393'
416394
417395test_expect_success ' push with ambiguity' '
418-
419396 mk_test testrepo heads/frotz tags/frotz &&
420397 test_must_fail git push testrepo main:frotz &&
421398 check_push_result testrepo $the_first_commit heads/frotz tags/frotz
422-
423399'
424400
425401test_expect_success ' push with onelevel ref' '
@@ -428,17 +404,14 @@ test_expect_success 'push with onelevel ref' '
428404'
429405
430406test_expect_success ' push with colon-less refspec (1)' '
431-
432407 mk_test testrepo heads/frotz tags/frotz &&
433408 git branch -f frotz main &&
434409 git push testrepo frotz &&
435410 check_push_result testrepo $the_commit heads/frotz &&
436411 check_push_result testrepo $the_first_commit tags/frotz
437-
438412'
439413
440414test_expect_success ' push with colon-less refspec (2)' '
441-
442415 mk_test testrepo heads/frotz tags/frotz &&
443416 if git show-ref --verify -q refs/heads/frotz
444417 then
@@ -448,7 +421,6 @@ test_expect_success 'push with colon-less refspec (2)' '
448421 git push -f testrepo frotz &&
449422 check_push_result testrepo $the_commit tags/frotz &&
450423 check_push_result testrepo $the_first_commit heads/frotz
451-
452424'
453425
454426test_expect_success ' push with colon-less refspec (3)' '
@@ -465,7 +437,6 @@ test_expect_success 'push with colon-less refspec (3)' '
465437'
466438
467439test_expect_success ' push with colon-less refspec (4)' '
468-
469440 mk_test testrepo &&
470441 if git show-ref --verify -q refs/heads/frotz
471442 then
@@ -475,38 +446,34 @@ test_expect_success 'push with colon-less refspec (4)' '
475446 git push testrepo frotz &&
476447 check_push_result testrepo $the_commit tags/frotz &&
477448 test 1 = $( cd testrepo && git show-ref | wc -l )
478-
479449'
480450
481451test_expect_success ' push head with non-existent, incomplete dest' '
482-
483452 mk_test testrepo &&
484453 git push testrepo main:branch &&
485454 check_push_result testrepo $the_commit heads/branch
486-
487455'
488456
489457test_expect_success ' push tag with non-existent, incomplete dest' '
490-
491458 mk_test testrepo &&
492459 git tag -f v1.0 &&
493460 git push testrepo v1.0:tag &&
494461 check_push_result testrepo $the_commit tags/tag
495-
496462'
497463
498464test_expect_success ' push oid with non-existent, incomplete dest' '
499-
500465 mk_test testrepo &&
501466 test_must_fail git push testrepo $(git rev-parse main):foo
502-
503467'
504468
505469test_expect_success ' push ref expression with non-existent, incomplete dest' '
506-
507470 mk_test testrepo &&
508471 test_must_fail git push testrepo main^:branch
472+ '
509473
474+ test_expect_success ' push ref expression with non-existent oid src' '
475+ mk_test testrepo &&
476+ test_must_fail git push testrepo $(test_oid 001):branch
510477'
511478
512479for head in HEAD @
550517 git checkout main &&
551518 git push testrepo $head:branch &&
552519 check_push_result testrepo $the_commit heads/branch
553-
554520 '
555521
556522 test_expect_success " push with config remote.*.push = $head " '
@@ -596,7 +562,6 @@ test_expect_success 'push with remote.pushdefault' '
596562'
597563
598564test_expect_success ' push with config remote.*.pushurl' '
599-
600565 mk_test testrepo heads/main &&
601566 git checkout main &&
602567 test_config remote.there.url test2repo &&
@@ -655,15 +620,13 @@ test_expect_success 'push ignores "branch." config without subsection' '
655620'
656621
657622test_expect_success ' push with dry-run' '
658-
659623 mk_test testrepo heads/main &&
660624 old_commit=$(git -C testrepo show-ref -s --verify refs/heads/main) &&
661625 git push --dry-run testrepo : &&
662626 check_push_result testrepo $old_commit heads/main
663627'
664628
665629test_expect_success ' push updates local refs' '
666-
667630 mk_test testrepo heads/main &&
668631 mk_child testrepo child &&
669632 (
@@ -673,11 +636,9 @@ test_expect_success 'push updates local refs' '
673636 test $(git rev-parse main) = \
674637 $(git rev-parse remotes/origin/main)
675638 )
676-
677639'
678640
679641test_expect_success ' push updates up-to-date local refs' '
680-
681642 mk_test testrepo heads/main &&
682643 mk_child testrepo child1 &&
683644 mk_child testrepo child2 &&
@@ -689,23 +650,19 @@ test_expect_success 'push updates up-to-date local refs' '
689650 test $(git rev-parse main) = \
690651 $(git rev-parse remotes/origin/main)
691652 )
692-
693653'
694654
695655test_expect_success ' push preserves up-to-date packed refs' '
696-
697656 mk_test testrepo heads/main &&
698657 mk_child testrepo child &&
699658 (
700659 cd child &&
701660 git push &&
702661 ! test -f .git/refs/remotes/origin/main
703662 )
704-
705663'
706664
707665test_expect_success ' push does not update local refs on failure' '
708-
709666 mk_test testrepo heads/main &&
710667 mk_child testrepo child &&
711668 echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
@@ -717,16 +674,13 @@ test_expect_success 'push does not update local refs on failure' '
717674 test $(git rev-parse main) != \
718675 $(git rev-parse remotes/origin/main)
719676 )
720-
721677'
722678
723679test_expect_success ' allow deleting an invalid remote ref' '
724-
725680 mk_test testrepo heads/branch &&
726681 rm -f testrepo/.git/objects/??/* &&
727682 git push testrepo :refs/heads/branch &&
728683 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/branch)
729-
730684'
731685
732686test_expect_success ' pushing valid refs triggers post-receive and post-update hooks' '
0 commit comments