@@ -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,29 @@ 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
509
-
510
472
'
511
473
512
474
for head in HEAD @
550
512
git checkout main &&
551
513
git push testrepo $head:branch &&
552
514
check_push_result testrepo $the_commit heads/branch
553
-
554
515
'
555
516
556
517
test_expect_success " push with config remote.*.push = $head " '
@@ -596,7 +557,6 @@ test_expect_success 'push with remote.pushdefault' '
596
557
'
597
558
598
559
test_expect_success ' push with config remote.*.pushurl' '
599
-
600
560
mk_test testrepo heads/main &&
601
561
git checkout main &&
602
562
test_config remote.there.url test2repo &&
@@ -655,15 +615,13 @@ test_expect_success 'push ignores "branch." config without subsection' '
655
615
'
656
616
657
617
test_expect_success ' push with dry-run' '
658
-
659
618
mk_test testrepo heads/main &&
660
619
old_commit=$(git -C testrepo show-ref -s --verify refs/heads/main) &&
661
620
git push --dry-run testrepo : &&
662
621
check_push_result testrepo $old_commit heads/main
663
622
'
664
623
665
624
test_expect_success ' push updates local refs' '
666
-
667
625
mk_test testrepo heads/main &&
668
626
mk_child testrepo child &&
669
627
(
@@ -673,11 +631,9 @@ test_expect_success 'push updates local refs' '
673
631
test $(git rev-parse main) = \
674
632
$(git rev-parse remotes/origin/main)
675
633
)
676
-
677
634
'
678
635
679
636
test_expect_success ' push updates up-to-date local refs' '
680
-
681
637
mk_test testrepo heads/main &&
682
638
mk_child testrepo child1 &&
683
639
mk_child testrepo child2 &&
@@ -689,23 +645,19 @@ test_expect_success 'push updates up-to-date local refs' '
689
645
test $(git rev-parse main) = \
690
646
$(git rev-parse remotes/origin/main)
691
647
)
692
-
693
648
'
694
649
695
650
test_expect_success ' push preserves up-to-date packed refs' '
696
-
697
651
mk_test testrepo heads/main &&
698
652
mk_child testrepo child &&
699
653
(
700
654
cd child &&
701
655
git push &&
702
656
! test -f .git/refs/remotes/origin/main
703
657
)
704
-
705
658
'
706
659
707
660
test_expect_success ' push does not update local refs on failure' '
708
-
709
661
mk_test testrepo heads/main &&
710
662
mk_child testrepo child &&
711
663
echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
@@ -717,16 +669,13 @@ test_expect_success 'push does not update local refs on failure' '
717
669
test $(git rev-parse main) != \
718
670
$(git rev-parse remotes/origin/main)
719
671
)
720
-
721
672
'
722
673
723
674
test_expect_success ' allow deleting an invalid remote ref' '
724
-
725
675
mk_test testrepo heads/branch &&
726
676
rm -f testrepo/.git/objects/??/* &&
727
677
git push testrepo :refs/heads/branch &&
728
678
(cd testrepo && test_must_fail git rev-parse --verify refs/heads/branch)
729
-
730
679
'
731
680
732
681
test_expect_success ' pushing valid refs triggers post-receive and post-update hooks' '
0 commit comments