3 test_description
='Basic fetch/push functionality.
5 This test checks the following functionality:
9 * fast-forward detection, and overriding it
12 * --porcelain output format
22 rm -fr "$repo_name" &&
27 git config receive.denyCurrentBranch warn
&&
28 mv .git
/hooks .git
/hooks-disabled
36 mk_empty
"$repo_name" &&
40 git push
"$repo_name" $the_first_commit:refs
/$ref ||
46 echo "$the_first_commit" >expect
&&
47 git show-ref
-s --verify refs
/$ref >actual
&&
48 test_cmp expect actual ||
55 mk_test_with_hooks
() {
63 cat >pre-receive
<<-'EOF' &&
65 cat - >>pre-receive.actual
68 cat >update
<<-'EOF' &&
70 printf "%s %s %s\n" "$@" >>update.actual
73 cat >post-receive
<<-'EOF' &&
75 cat - >>post-receive.actual
78 cat >post-update
<<-'EOF' &&
82 printf "%s\n" "$ref" >>post-update.actual
86 chmod +x pre-receive update post-receive post-update
95 check_push_result
() {
105 git show-ref
-s --verify refs
/$ref >actual
&&
106 test_cmp expect actual ||
113 test_expect_success setup
'
118 git commit -a -m repo &&
119 the_first_commit=$(git show-ref -s --verify refs/heads/master) &&
124 git commit -a -m second &&
125 the_commit=$(git show-ref -s --verify refs/heads/master)
129 test_expect_success
'fetch without wildcard' '
133 git fetch .. refs/heads/master:refs/remotes/origin/master &&
135 echo "$the_commit commit refs/remotes/origin/master" >expect &&
136 git for-each-ref refs/remotes/origin >actual &&
137 test_cmp expect actual
141 test_expect_success
'fetch with wildcard' '
145 git config remote.up.url .. &&
146 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
149 echo "$the_commit commit refs/remotes/origin/master" >expect &&
150 git for-each-ref refs/remotes/origin >actual &&
151 test_cmp expect actual
155 test_expect_success
'fetch with insteadOf' '
160 git config "url.$TRASH.insteadOf" trash/ &&
161 git config remote.up.url trash/. &&
162 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
165 echo "$the_commit commit refs/remotes/origin/master" >expect &&
166 git for-each-ref refs/remotes/origin >actual &&
167 test_cmp expect actual
171 test_expect_success
'fetch with pushInsteadOf (should not rewrite)' '
176 git config "url.trash/.pushInsteadOf" "$TRASH" &&
177 git config remote.up.url "$TRASH." &&
178 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
181 echo "$the_commit commit refs/remotes/origin/master" >expect &&
182 git for-each-ref refs/remotes/origin >actual &&
183 test_cmp expect actual
187 test_expect_success
'push without wildcard' '
190 git push testrepo refs/heads/master:refs/remotes/origin/master &&
193 echo "$the_commit commit refs/remotes/origin/master" >expect &&
194 git for-each-ref refs/remotes/origin >actual &&
195 test_cmp expect actual
199 test_expect_success
'push with wildcard' '
202 git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
205 echo "$the_commit commit refs/remotes/origin/master" >expect &&
206 git for-each-ref refs/remotes/origin >actual &&
207 test_cmp expect actual
211 test_expect_success
'push with insteadOf' '
214 test_config "url.$TRASH.insteadOf" trash/ &&
215 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
218 echo "$the_commit commit refs/remotes/origin/master" >expect &&
219 git for-each-ref refs/remotes/origin >actual &&
220 test_cmp expect actual
224 test_expect_success
'push with pushInsteadOf' '
227 test_config "url.$TRASH.pushInsteadOf" trash/ &&
228 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
231 echo "$the_commit commit refs/remotes/origin/master" >expect &&
232 git for-each-ref refs/remotes/origin >actual &&
233 test_cmp expect actual
237 test_expect_success
'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
240 test_config "url.trash2/.pushInsteadOf" trash/ &&
241 test_config remote.r.url trash/wrong &&
242 test_config remote.r.pushurl "$TRASH/testrepo" &&
243 git push r refs/heads/master:refs/remotes/origin/master &&
246 echo "$the_commit commit refs/remotes/origin/master" >expect &&
247 git for-each-ref refs/remotes/origin >actual &&
248 test_cmp expect actual
252 test_expect_success
'push with matching heads' '
254 mk_test testrepo heads/master &&
256 check_push_result testrepo $the_commit heads/master
260 test_expect_success
'push with matching heads on the command line' '
262 mk_test testrepo heads/master &&
263 git push testrepo : &&
264 check_push_result testrepo $the_commit heads/master
268 test_expect_success
'failed (non-fast-forward) push with matching heads' '
270 mk_test testrepo heads/master &&
271 git push testrepo : &&
272 git commit --amend -massaged &&
273 test_must_fail git push testrepo &&
274 check_push_result testrepo $the_commit heads/master &&
275 git reset --hard $the_commit
279 test_expect_success
'push --force with matching heads' '
281 mk_test testrepo heads/master &&
282 git push testrepo : &&
283 git commit --amend -massaged &&
284 git push --force testrepo &&
285 ! check_push_result testrepo $the_commit heads/master &&
286 git reset --hard $the_commit
290 test_expect_success
'push with matching heads and forced update' '
292 mk_test testrepo heads/master &&
293 git push testrepo : &&
294 git commit --amend -massaged &&
295 git push testrepo +: &&
296 ! check_push_result testrepo $the_commit heads/master &&
297 git reset --hard $the_commit
301 test_expect_success
'push with no ambiguity (1)' '
303 mk_test testrepo heads/master &&
304 git push testrepo master:master &&
305 check_push_result testrepo $the_commit heads/master
309 test_expect_success
'push with no ambiguity (2)' '
311 mk_test testrepo remotes/origin/master &&
312 git push testrepo master:origin/master &&
313 check_push_result testrepo $the_commit remotes/origin/master
317 test_expect_success
'push with colon-less refspec, no ambiguity' '
319 mk_test testrepo heads/master heads/t/master &&
320 git branch -f t/master master &&
321 git push testrepo master &&
322 check_push_result testrepo $the_commit heads/master &&
323 check_push_result testrepo $the_first_commit heads/t/master
327 test_expect_success
'push with weak ambiguity (1)' '
329 mk_test testrepo heads/master remotes/origin/master &&
330 git push testrepo master:master &&
331 check_push_result testrepo $the_commit heads/master &&
332 check_push_result testrepo $the_first_commit remotes/origin/master
336 test_expect_success
'push with weak ambiguity (2)' '
338 mk_test testrepo heads/master remotes/origin/master remotes/another/master &&
339 git push testrepo master:master &&
340 check_push_result testrepo $the_commit heads/master &&
341 check_push_result testrepo $the_first_commit remotes/origin/master remotes/another/master
345 test_expect_success
'push with ambiguity' '
347 mk_test testrepo heads/frotz tags/frotz &&
348 test_must_fail git push testrepo master:frotz &&
349 check_push_result testrepo $the_first_commit heads/frotz tags/frotz
353 test_expect_success
'push with colon-less refspec (1)' '
355 mk_test testrepo heads/frotz tags/frotz &&
356 git branch -f frotz master &&
357 git push testrepo frotz &&
358 check_push_result testrepo $the_commit heads/frotz &&
359 check_push_result testrepo $the_first_commit tags/frotz
363 test_expect_success
'push with colon-less refspec (2)' '
365 mk_test testrepo heads/frotz tags/frotz &&
366 if git show-ref --verify -q refs/heads/frotz
371 git push -f testrepo frotz &&
372 check_push_result testrepo $the_commit tags/frotz &&
373 check_push_result testrepo $the_first_commit heads/frotz
377 test_expect_success
'push with colon-less refspec (3)' '
380 if git show-ref --verify -q refs/tags/frotz
384 git branch -f frotz master &&
385 git push testrepo frotz &&
386 check_push_result testrepo $the_commit heads/frotz &&
387 test 1 = $( cd testrepo && git show-ref | wc -l )
390 test_expect_success
'push with colon-less refspec (4)' '
393 if git show-ref --verify -q refs/heads/frotz
398 git push testrepo frotz &&
399 check_push_result testrepo $the_commit tags/frotz &&
400 test 1 = $( cd testrepo && git show-ref | wc -l )
404 test_expect_success
'push head with non-existent, incomplete dest' '
407 git push testrepo master:branch &&
408 check_push_result testrepo $the_commit heads/branch
412 test_expect_success
'push tag with non-existent, incomplete dest' '
416 git push testrepo v1.0:tag &&
417 check_push_result testrepo $the_commit tags/tag
421 test_expect_success
'push sha1 with non-existent, incomplete dest' '
424 test_must_fail git push testrepo `git rev-parse master`:foo
428 test_expect_success
'push ref expression with non-existent, incomplete dest' '
431 test_must_fail git push testrepo master^:branch
435 test_expect_success
'push with HEAD' '
437 mk_test testrepo heads/master &&
438 git checkout master &&
439 git push testrepo HEAD &&
440 check_push_result testrepo $the_commit heads/master
444 test_expect_success
'push with HEAD nonexisting at remote' '
446 mk_test testrepo heads/master &&
447 git checkout -b local master &&
448 git push testrepo HEAD &&
449 check_push_result testrepo $the_commit heads/local
452 test_expect_success
'push with +HEAD' '
454 mk_test testrepo heads/master &&
455 git checkout master &&
456 git branch -D local &&
457 git checkout -b local &&
458 git push testrepo master local &&
459 check_push_result testrepo $the_commit heads/master &&
460 check_push_result testrepo $the_commit heads/local &&
462 # Without force rewinding should fail
463 git reset --hard HEAD^ &&
464 test_must_fail git push testrepo HEAD &&
465 check_push_result testrepo $the_commit heads/local &&
467 # With force rewinding should succeed
468 git push testrepo +HEAD &&
469 check_push_result testrepo $the_first_commit heads/local
473 test_expect_success
'push HEAD with non-existent, incomplete dest' '
476 git checkout master &&
477 git push testrepo HEAD:branch &&
478 check_push_result testrepo $the_commit heads/branch
482 test_expect_success
'push with config remote.*.push = HEAD' '
484 mk_test testrepo heads/local &&
485 git checkout master &&
486 git branch -f local $the_commit &&
489 git checkout local &&
490 git reset --hard $the_first_commit
492 test_config remote.there.url testrepo &&
493 test_config remote.there.push HEAD &&
494 test_config branch.master.remote there &&
496 check_push_result testrepo $the_commit heads/master &&
497 check_push_result testrepo $the_first_commit heads/local
500 test_expect_success
'push with config remote.*.pushurl' '
502 mk_test testrepo heads/master &&
503 git checkout master &&
504 test_config remote.there.url test2repo &&
505 test_config remote.there.pushurl testrepo &&
507 check_push_result testrepo $the_commit heads/master
510 test_expect_success
'push with dry-run' '
512 mk_test testrepo heads/master &&
515 old_commit=$(git show-ref -s --verify refs/heads/master)
517 git push --dry-run testrepo &&
518 check_push_result testrepo $old_commit heads/master
521 test_expect_success
'push updates local refs' '
523 mk_test testrepo heads/master &&
524 mk_child testrepo child &&
527 git pull .. master &&
529 test $(git rev-parse master) = \
530 $(git rev-parse remotes/origin/master)
535 test_expect_success
'push updates up-to-date local refs' '
537 mk_test testrepo heads/master &&
538 mk_child testrepo child1 &&
539 mk_child testrepo child2 &&
540 (cd child1 && git pull .. master && git push) &&
543 git pull ../child1 master &&
545 test $(git rev-parse master) = \
546 $(git rev-parse remotes/origin/master)
551 test_expect_success
'push preserves up-to-date packed refs' '
553 mk_test testrepo heads/master &&
554 mk_child testrepo child &&
558 ! test -f .git/refs/remotes/origin/master
563 test_expect_success
'push does not update local refs on failure' '
565 mk_test testrepo heads/master &&
566 mk_child testrepo child &&
567 mkdir testrepo/.git/hooks &&
568 echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
569 chmod +x testrepo/.git/hooks/pre-receive &&
573 test_must_fail git push &&
574 test $(git rev-parse master) != \
575 $(git rev-parse remotes/origin/master)
580 test_expect_success
'allow deleting an invalid remote ref' '
582 mk_test testrepo heads/master &&
583 rm -f testrepo/.git/objects/??/* &&
584 git push testrepo :refs/heads/master &&
585 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
589 test_expect_success
'pushing valid refs triggers post-receive and post-update hooks' '
590 mk_test_with_hooks testrepo heads/master heads/next &&
591 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
592 newmaster=$(git show-ref -s --verify refs/heads/master) &&
593 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
595 git push testrepo refs/heads/master:refs/heads/master :refs/heads/next &&
598 cat >pre-receive.expect <<-EOF &&
599 $orgmaster $newmaster refs/heads/master
600 $orgnext $newnext refs/heads/next
603 cat >update.expect <<-EOF &&
604 refs/heads/master $orgmaster $newmaster
605 refs/heads/next $orgnext $newnext
608 cat >post-receive.expect <<-EOF &&
609 $orgmaster $newmaster refs/heads/master
610 $orgnext $newnext refs/heads/next
613 cat >post-update.expect <<-EOF &&
618 test_cmp pre-receive.expect pre-receive.actual &&
619 test_cmp update.expect update.actual &&
620 test_cmp post-receive.expect post-receive.actual &&
621 test_cmp post-update.expect post-update.actual
625 test_expect_success
'deleting dangling ref triggers hooks with correct args' '
626 mk_test_with_hooks testrepo heads/master &&
627 rm -f testrepo/.git/objects/??/* &&
628 git push testrepo :refs/heads/master &&
631 cat >pre-receive.expect <<-EOF &&
632 $_z40 $_z40 refs/heads/master
635 cat >update.expect <<-EOF &&
636 refs/heads/master $_z40 $_z40
639 cat >post-receive.expect <<-EOF &&
640 $_z40 $_z40 refs/heads/master
643 cat >post-update.expect <<-EOF &&
647 test_cmp pre-receive.expect pre-receive.actual &&
648 test_cmp update.expect update.actual &&
649 test_cmp post-receive.expect post-receive.actual &&
650 test_cmp post-update.expect post-update.actual
654 test_expect_success
'deletion of a non-existent ref is not fed to post-receive and post-update hooks' '
655 mk_test_with_hooks testrepo heads/master &&
656 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
657 newmaster=$(git show-ref -s --verify refs/heads/master) &&
658 git push testrepo master :refs/heads/nonexistent &&
661 cat >pre-receive.expect <<-EOF &&
662 $orgmaster $newmaster refs/heads/master
663 $_z40 $_z40 refs/heads/nonexistent
666 cat >update.expect <<-EOF &&
667 refs/heads/master $orgmaster $newmaster
668 refs/heads/nonexistent $_z40 $_z40
671 cat >post-receive.expect <<-EOF &&
672 $orgmaster $newmaster refs/heads/master
675 cat >post-update.expect <<-EOF &&
679 test_cmp pre-receive.expect pre-receive.actual &&
680 test_cmp update.expect update.actual &&
681 test_cmp post-receive.expect post-receive.actual &&
682 test_cmp post-update.expect post-update.actual
686 test_expect_success
'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' '
687 mk_test_with_hooks testrepo heads/master &&
688 git push testrepo :refs/heads/nonexistent &&
691 cat >pre-receive.expect <<-EOF &&
692 $_z40 $_z40 refs/heads/nonexistent
695 cat >update.expect <<-EOF &&
696 refs/heads/nonexistent $_z40 $_z40
699 test_cmp pre-receive.expect pre-receive.actual &&
700 test_cmp update.expect update.actual &&
701 test_path_is_missing post-receive.actual &&
702 test_path_is_missing post-update.actual
706 test_expect_success
'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' '
707 mk_test_with_hooks testrepo heads/master heads/next heads/pu &&
708 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
709 newmaster=$(git show-ref -s --verify refs/heads/master) &&
710 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
712 orgpu=$(cd testrepo && git show-ref -s --verify refs/heads/pu) &&
713 newpu=$(git show-ref -s --verify refs/heads/master) &&
714 git push testrepo refs/heads/master:refs/heads/master \
715 refs/heads/master:refs/heads/pu :refs/heads/next \
716 :refs/heads/nonexistent &&
719 cat >pre-receive.expect <<-EOF &&
720 $orgmaster $newmaster refs/heads/master
721 $orgnext $newnext refs/heads/next
722 $orgpu $newpu refs/heads/pu
723 $_z40 $_z40 refs/heads/nonexistent
726 cat >update.expect <<-EOF &&
727 refs/heads/master $orgmaster $newmaster
728 refs/heads/next $orgnext $newnext
729 refs/heads/pu $orgpu $newpu
730 refs/heads/nonexistent $_z40 $_z40
733 cat >post-receive.expect <<-EOF &&
734 $orgmaster $newmaster refs/heads/master
735 $orgnext $newnext refs/heads/next
736 $orgpu $newpu refs/heads/pu
739 cat >post-update.expect <<-EOF &&
745 test_cmp pre-receive.expect pre-receive.actual &&
746 test_cmp update.expect update.actual &&
747 test_cmp post-receive.expect post-receive.actual &&
748 test_cmp post-update.expect post-update.actual
752 test_expect_success
'allow deleting a ref using --delete' '
753 mk_test testrepo heads/master &&
754 (cd testrepo && git config receive.denyDeleteCurrent warn) &&
755 git push testrepo --delete master &&
756 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
759 test_expect_success
'allow deleting a tag using --delete' '
760 mk_test testrepo heads/master &&
761 git tag -a -m dummy_message deltag heads/master &&
762 git push testrepo --tags &&
763 (cd testrepo && git rev-parse --verify -q refs/tags/deltag) &&
764 git push testrepo --delete tag deltag &&
765 (cd testrepo && test_must_fail git rev-parse --verify refs/tags/deltag)
768 test_expect_success
'push --delete without args aborts' '
769 mk_test testrepo heads/master &&
770 test_must_fail git push testrepo --delete
773 test_expect_success
'push --delete refuses src:dest refspecs' '
774 mk_test testrepo heads/master &&
775 test_must_fail git push testrepo --delete master:foo
778 test_expect_success
'warn on push to HEAD of non-bare repository' '
779 mk_test testrepo heads/master &&
782 git checkout master &&
783 git config receive.denyCurrentBranch warn
785 git push testrepo master 2>stderr &&
786 grep "warning: updating the current branch" stderr
789 test_expect_success
'deny push to HEAD of non-bare repository' '
790 mk_test testrepo heads/master &&
793 git checkout master &&
794 git config receive.denyCurrentBranch true
796 test_must_fail git push testrepo master
799 test_expect_success
'allow push to HEAD of bare repository (bare)' '
800 mk_test testrepo heads/master &&
803 git checkout master &&
804 git config receive.denyCurrentBranch true &&
805 git config core.bare true
807 git push testrepo master 2>stderr &&
808 ! grep "warning: updating the current branch" stderr
811 test_expect_success
'allow push to HEAD of non-bare repository (config)' '
812 mk_test testrepo heads/master &&
815 git checkout master &&
816 git config receive.denyCurrentBranch false
818 git push testrepo master 2>stderr &&
819 ! grep "warning: updating the current branch" stderr
822 test_expect_success
'fetch with branches' '
824 git branch second $the_first_commit &&
825 git checkout second &&
826 echo ".." > testrepo/.git/branches/branch1 &&
830 echo "$the_commit commit refs/heads/branch1" >expect &&
831 git for-each-ref refs/heads >actual &&
832 test_cmp expect actual
837 test_expect_success
'fetch with branches containing #' '
839 echo "..#second" > testrepo/.git/branches/branch2 &&
843 echo "$the_first_commit commit refs/heads/branch2" >expect &&
844 git for-each-ref refs/heads >actual &&
845 test_cmp expect actual
850 test_expect_success
'push with branches' '
852 git checkout second &&
853 echo "testrepo" > .git/branches/branch1 &&
857 echo "$the_first_commit commit refs/heads/master" >expect &&
858 git for-each-ref refs/heads >actual &&
859 test_cmp expect actual
863 test_expect_success
'push with branches containing #' '
865 echo "testrepo#branch3" > .git/branches/branch2 &&
869 echo "$the_first_commit commit refs/heads/branch3" >expect &&
870 git for-each-ref refs/heads >actual &&
871 test_cmp expect actual
876 test_expect_success
'push into aliased refs (consistent)' '
877 mk_test testrepo heads/master &&
878 mk_child testrepo child1 &&
879 mk_child testrepo child2 &&
883 git symbolic-ref refs/heads/bar refs/heads/foo
884 git config receive.denyCurrentBranch false
891 git commit -a -m child2 &&
894 git push ../child1 foo bar
898 test_expect_success
'push into aliased refs (inconsistent)' '
899 mk_test testrepo heads/master &&
900 mk_child testrepo child1 &&
901 mk_child testrepo child2 &&
905 git symbolic-ref refs/heads/bar refs/heads/foo
906 git config receive.denyCurrentBranch false
913 git commit -a -m child2 &&
918 git commit -a -m child2 &&
920 test_must_fail git push ../child1 foo bar 2>stderr &&
921 grep "refusing inconsistent update" stderr
925 test_expect_success
'push requires --force to update lightweight tag' '
926 mk_test testrepo heads/master &&
927 mk_child testrepo child1 &&
928 mk_child testrepo child2 &&
932 git push ../child2 Tag &&
933 git push ../child2 Tag &&
936 git commit -m "file1" &&
938 test_must_fail git push ../child2 Tag &&
939 git push --force ../child2 Tag &&
941 test_must_fail git push ../child2 Tag HEAD~ &&
942 git push --force ../child2 Tag
946 test_expect_success
'push --porcelain' '
948 echo >.git/foo "To testrepo" &&
949 echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
950 echo >>.git/foo "Done" &&
951 git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
954 echo "$the_commit commit refs/remotes/origin/master" >expect &&
955 git for-each-ref refs/remotes/origin >actual &&
956 test_cmp expect actual
958 test_cmp .git/foo .git/bar
961 test_expect_success
'push --porcelain bad url' '
963 test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
964 test_must_fail grep -q Done .git/bar
967 test_expect_success
'push --porcelain rejected' '
969 git push testrepo refs/heads/master:refs/remotes/origin/master &&
971 git reset --hard origin/master^
972 git config receive.denyCurrentBranch true) &&
974 echo >.git/foo "To testrepo" &&
975 echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
977 test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
978 test_cmp .git/foo .git/bar
981 test_expect_success
'push --porcelain --dry-run rejected' '
983 git push testrepo refs/heads/master:refs/remotes/origin/master &&
985 git reset --hard origin/master
986 git config receive.denyCurrentBranch true) &&
988 echo >.git/foo "To testrepo" &&
989 echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" &&
990 echo >>.git/foo "Done" &&
992 test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master &&
993 test_cmp .git/foo .git/bar
996 test_expect_success
'push --prune' '
997 mk_test testrepo heads/master heads/second heads/foo heads/bar &&
998 git push --prune testrepo &&
999 check_push_result testrepo $the_commit heads/master &&
1000 check_push_result testrepo $the_first_commit heads/second &&
1001 ! check_push_result testrepo $the_first_commit heads/foo heads/bar
1004 test_expect_success
'push --prune refspec' '
1005 mk_test testrepo tmp/master tmp/second tmp/foo tmp/bar &&
1006 git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
1007 check_push_result testrepo $the_commit tmp/master &&
1008 check_push_result testrepo $the_first_commit tmp/second &&
1009 ! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
1012 for configsection
in transfer receive
1014 test_expect_success
"push to update a ref hidden by $configsection.hiderefs" '
1015 mk_test testrepo heads/master hidden/one hidden/two hidden/three &&
1018 git config $configsection.hiderefs refs/hidden
1021 # push to unhidden ref succeeds normally
1022 git push testrepo master:refs/heads/master &&
1023 check_push_result testrepo $the_commit heads/master &&
1025 # push to update a hidden ref should fail
1026 test_must_fail git push testrepo master:refs/hidden/one &&
1027 check_push_result testrepo $the_first_commit hidden/one &&
1029 # push to delete a hidden ref should fail
1030 test_must_fail git push testrepo :refs/hidden/two &&
1031 check_push_result testrepo $the_first_commit hidden/two &&
1033 # idempotent push to update a hidden ref should fail
1034 test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
1035 check_push_result testrepo $the_first_commit hidden/three
1039 test_expect_success
'fetch exact SHA1' '
1040 mk_test testrepo heads/master hidden/one &&
1041 git push testrepo master:refs/hidden/one &&
1044 git config transfer.hiderefs refs/hidden
1046 check_push_result testrepo $the_commit hidden/one &&
1048 mk_child testrepo child &&
1052 # make sure $the_commit does not exist here
1055 test_must_fail git cat-file -t $the_commit &&
1057 # fetching the hidden object should fail by default
1058 test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1059 test_must_fail git rev-parse --verify refs/heads/copy &&
1061 # the server side can allow it to succeed
1064 git config uploadpack.allowtipsha1inwant true
1067 git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1068 result=$(git rev-parse --verify refs/heads/copy) &&
1069 test "$the_commit" = "$result"
1073 test_expect_success
'fetch follows tags by default' '
1074 mk_test testrepo heads/master &&
1079 git pull ../testrepo master &&
1080 git tag -m "annotated" tag &&
1081 git for-each-ref >tmp1 &&
1084 sed -n "s|refs/heads/master$|refs/remotes/origin/master|p" tmp1
1086 sort -k 3 >../expect
1091 git remote add origin ../src &&
1092 git config branch.master.remote origin &&
1093 git config branch.master.merge refs/heads/master &&
1095 git for-each-ref >../actual
1097 test_cmp expect actual
1100 test_expect_success
'push does not follow tags by default' '
1101 mk_test testrepo heads/master &&
1104 git init --bare dst &&
1107 git pull ../testrepo master &&
1108 git tag -m "annotated" tag &&
1109 git checkout -b another &&
1110 git commit --allow-empty -m "future commit" &&
1111 git tag -m "future" future &&
1112 git checkout master &&
1113 git for-each-ref refs/heads/master >../expect &&
1114 git push ../dst master
1118 git for-each-ref >../actual
1120 test_cmp expect actual
1123 test_expect_success
'push --follow-tag only pushes relevant tags' '
1124 mk_test testrepo heads/master &&
1127 git init --bare dst &&
1130 git pull ../testrepo master &&
1131 git tag -m "annotated" tag &&
1132 git checkout -b another &&
1133 git commit --allow-empty -m "future commit" &&
1134 git tag -m "future" future &&
1135 git checkout master &&
1136 git for-each-ref refs/heads/master refs/tags/tag >../expect
1137 git push --follow-tag ../dst master
1141 git for-each-ref >../actual
1143 test_cmp expect actual