@@ -105,7 +105,6 @@ check_push_result () {
105
105
}
106
106
107
107
test_expect_success setup '
108
-
109
108
>path1 &&
110
109
git add path1 &&
111
110
test_tick &&
@@ -117,7 +116,6 @@ test_expect_success setup '
117
116
test_tick &&
118
117
git commit -a -m second &&
119
118
the_commit=$(git show-ref -s --verify refs/heads/main)
120
-
121
119
'
122
120
123
121
for cmd in push fetch
@@ -322,104 +320,82 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf
322
320
'
323
321
324
322
test_expect_success ' push with matching heads' '
325
-
326
323
mk_test testrepo heads/main &&
327
324
git push testrepo : &&
328
325
check_push_result testrepo $the_commit heads/main
329
-
330
326
'
331
327
332
328
test_expect_success ' push with matching heads on the command line' '
333
-
334
329
mk_test testrepo heads/main &&
335
330
git push testrepo : &&
336
331
check_push_result testrepo $the_commit heads/main
337
-
338
332
'
339
333
340
334
test_expect_success ' failed (non-fast-forward) push with matching heads' '
341
-
342
335
mk_test testrepo heads/main &&
343
336
git push testrepo : &&
344
337
git commit --amend -massaged &&
345
338
test_must_fail git push testrepo &&
346
339
check_push_result testrepo $the_commit heads/main &&
347
340
git reset --hard $the_commit
348
-
349
341
'
350
342
351
343
test_expect_success ' push --force with matching heads' '
352
-
353
344
mk_test testrepo heads/main &&
354
345
git push testrepo : &&
355
346
git commit --amend -massaged &&
356
347
git push --force testrepo : &&
357
348
! check_push_result testrepo $the_commit heads/main &&
358
349
git reset --hard $the_commit
359
-
360
350
'
361
351
362
352
test_expect_success ' push with matching heads and forced update' '
363
-
364
353
mk_test testrepo heads/main &&
365
354
git push testrepo : &&
366
355
git commit --amend -massaged &&
367
356
git push testrepo +: &&
368
357
! check_push_result testrepo $the_commit heads/main &&
369
358
git reset --hard $the_commit
370
-
371
359
'
372
360
373
361
test_expect_success ' push with no ambiguity (1)' '
374
-
375
362
mk_test testrepo heads/main &&
376
363
git push testrepo main:main &&
377
364
check_push_result testrepo $the_commit heads/main
378
-
379
365
'
380
366
381
367
test_expect_success ' push with no ambiguity (2)' '
382
-
383
368
mk_test testrepo remotes/origin/main &&
384
369
git push testrepo main:origin/main &&
385
370
check_push_result testrepo $the_commit remotes/origin/main
386
-
387
371
'
388
372
389
373
test_expect_success ' push with colon-less refspec, no ambiguity' '
390
-
391
374
mk_test testrepo heads/main heads/t/main &&
392
375
git branch -f t/main main &&
393
376
git push testrepo main &&
394
377
check_push_result testrepo $the_commit heads/main &&
395
378
check_push_result testrepo $the_first_commit heads/t/main
396
-
397
379
'
398
380
399
381
test_expect_success ' push with weak ambiguity (1)' '
400
-
401
382
mk_test testrepo heads/main remotes/origin/main &&
402
383
git push testrepo main:main &&
403
384
check_push_result testrepo $the_commit heads/main &&
404
385
check_push_result testrepo $the_first_commit remotes/origin/main
405
-
406
386
'
407
387
408
388
test_expect_success ' push with weak ambiguity (2)' '
409
-
410
389
mk_test testrepo heads/main remotes/origin/main remotes/another/main &&
411
390
git push testrepo main:main &&
412
391
check_push_result testrepo $the_commit heads/main &&
413
392
check_push_result testrepo $the_first_commit remotes/origin/main remotes/another/main
414
-
415
393
'
416
394
417
395
test_expect_success ' push with ambiguity' '
418
-
419
396
mk_test testrepo heads/frotz tags/frotz &&
420
397
test_must_fail git push testrepo main:frotz &&
421
398
check_push_result testrepo $the_first_commit heads/frotz tags/frotz
422
-
423
399
'
424
400
425
401
test_expect_success ' push with onelevel ref' '
@@ -428,17 +404,14 @@ test_expect_success 'push with onelevel ref' '
428
404
'
429
405
430
406
test_expect_success ' push with colon-less refspec (1)' '
431
-
432
407
mk_test testrepo heads/frotz tags/frotz &&
433
408
git branch -f frotz main &&
434
409
git push testrepo frotz &&
435
410
check_push_result testrepo $the_commit heads/frotz &&
436
411
check_push_result testrepo $the_first_commit tags/frotz
437
-
438
412
'
439
413
440
414
test_expect_success ' push with colon-less refspec (2)' '
441
-
442
415
mk_test testrepo heads/frotz tags/frotz &&
443
416
if git show-ref --verify -q refs/heads/frotz
444
417
then
@@ -448,7 +421,6 @@ test_expect_success 'push with colon-less refspec (2)' '
448
421
git push -f testrepo frotz &&
449
422
check_push_result testrepo $the_commit tags/frotz &&
450
423
check_push_result testrepo $the_first_commit heads/frotz
451
-
452
424
'
453
425
454
426
test_expect_success ' push with colon-less refspec (3)' '
@@ -465,7 +437,6 @@ test_expect_success 'push with colon-less refspec (3)' '
465
437
'
466
438
467
439
test_expect_success ' push with colon-less refspec (4)' '
468
-
469
440
mk_test testrepo &&
470
441
if git show-ref --verify -q refs/heads/frotz
471
442
then
@@ -475,38 +446,34 @@ test_expect_success 'push with colon-less refspec (4)' '
475
446
git push testrepo frotz &&
476
447
check_push_result testrepo $the_commit tags/frotz &&
477
448
test 1 = $( cd testrepo && git show-ref | wc -l )
478
-
479
449
'
480
450
481
451
test_expect_success ' push head with non-existent, incomplete dest' '
482
-
483
452
mk_test testrepo &&
484
453
git push testrepo main:branch &&
485
454
check_push_result testrepo $the_commit heads/branch
486
-
487
455
'
488
456
489
457
test_expect_success ' push tag with non-existent, incomplete dest' '
490
-
491
458
mk_test testrepo &&
492
459
git tag -f v1.0 &&
493
460
git push testrepo v1.0:tag &&
494
461
check_push_result testrepo $the_commit tags/tag
495
-
496
462
'
497
463
498
464
test_expect_success ' push oid with non-existent, incomplete dest' '
499
-
500
465
mk_test testrepo &&
501
466
test_must_fail git push testrepo $(git rev-parse main):foo
502
-
503
467
'
504
468
505
469
test_expect_success ' push ref expression with non-existent, incomplete dest' '
506
-
507
470
mk_test testrepo &&
508
471
test_must_fail git push testrepo main^:branch
472
+ '
509
473
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
510
477
'
511
478
512
479
for head in HEAD @
550
517
git checkout main &&
551
518
git push testrepo $head:branch &&
552
519
check_push_result testrepo $the_commit heads/branch
553
-
554
520
'
555
521
556
522
test_expect_success " push with config remote.*.push = $head " '
@@ -596,7 +562,6 @@ test_expect_success 'push with remote.pushdefault' '
596
562
'
597
563
598
564
test_expect_success ' push with config remote.*.pushurl' '
599
-
600
565
mk_test testrepo heads/main &&
601
566
git checkout main &&
602
567
test_config remote.there.url test2repo &&
@@ -655,15 +620,13 @@ test_expect_success 'push ignores "branch." config without subsection' '
655
620
'
656
621
657
622
test_expect_success ' push with dry-run' '
658
-
659
623
mk_test testrepo heads/main &&
660
624
old_commit=$(git -C testrepo show-ref -s --verify refs/heads/main) &&
661
625
git push --dry-run testrepo : &&
662
626
check_push_result testrepo $old_commit heads/main
663
627
'
664
628
665
629
test_expect_success ' push updates local refs' '
666
-
667
630
mk_test testrepo heads/main &&
668
631
mk_child testrepo child &&
669
632
(
@@ -673,11 +636,9 @@ test_expect_success 'push updates local refs' '
673
636
test $(git rev-parse main) = \
674
637
$(git rev-parse remotes/origin/main)
675
638
)
676
-
677
639
'
678
640
679
641
test_expect_success ' push updates up-to-date local refs' '
680
-
681
642
mk_test testrepo heads/main &&
682
643
mk_child testrepo child1 &&
683
644
mk_child testrepo child2 &&
@@ -689,23 +650,19 @@ test_expect_success 'push updates up-to-date local refs' '
689
650
test $(git rev-parse main) = \
690
651
$(git rev-parse remotes/origin/main)
691
652
)
692
-
693
653
'
694
654
695
655
test_expect_success ' push preserves up-to-date packed refs' '
696
-
697
656
mk_test testrepo heads/main &&
698
657
mk_child testrepo child &&
699
658
(
700
659
cd child &&
701
660
git push &&
702
661
! test -f .git/refs/remotes/origin/main
703
662
)
704
-
705
663
'
706
664
707
665
test_expect_success ' push does not update local refs on failure' '
708
-
709
666
mk_test testrepo heads/main &&
710
667
mk_child testrepo child &&
711
668
echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
@@ -717,16 +674,13 @@ test_expect_success 'push does not update local refs on failure' '
717
674
test $(git rev-parse main) != \
718
675
$(git rev-parse remotes/origin/main)
719
676
)
720
-
721
677
'
722
678
723
679
test_expect_success ' allow deleting an invalid remote ref' '
724
-
725
680
mk_test testrepo heads/branch &&
726
681
rm -f testrepo/.git/objects/??/* &&
727
682
git push testrepo :refs/heads/branch &&
728
683
(cd testrepo && test_must_fail git rev-parse --verify refs/heads/branch)
729
-
730
684
'
731
685
732
686
test_expect_success ' pushing valid refs triggers post-receive and post-update hooks' '
0 commit comments