3 test_description
='fetching and pushing, with or without wildcard'
15 git config receive.denyCurrentBranch warn
&&
16 mv .git
/hooks .git
/hooks-disabled
25 git push testrepo
$the_first_commit:refs
/$ref ||
31 echo "$the_first_commit" >expect
&&
32 git show-ref
-s --verify refs
/$ref >actual
&&
33 test_cmp expect actual ||
40 mk_test_with_hooks
() {
47 cat >pre-receive
<<-'EOF' &&
49 cat - >>pre-receive.actual
52 cat >update
<<-'EOF' &&
54 printf "%s %s %s\n" "$@" >>update.actual
57 cat >post-receive
<<-'EOF' &&
59 cat - >>post-receive.actual
62 cat >post-update
<<-'EOF' &&
66 printf "%s\n" "$ref" >>post-update.actual
70 chmod +x pre-receive update post-receive post-update
76 git clone testrepo
"$1"
79 check_push_result
() {
86 git show-ref
-s --verify refs
/$ref >actual
&&
87 test_cmp expect actual ||
94 test_expect_success setup
'
99 git commit -a -m repo &&
100 the_first_commit=$(git show-ref -s --verify refs/heads/master) &&
105 git commit -a -m second &&
106 the_commit=$(git show-ref -s --verify refs/heads/master)
110 test_expect_success
'fetch without wildcard' '
114 git fetch .. refs/heads/master:refs/remotes/origin/master &&
116 echo "$the_commit commit refs/remotes/origin/master" >expect &&
117 git for-each-ref refs/remotes/origin >actual &&
118 test_cmp expect actual
122 test_expect_success
'fetch with wildcard' '
126 git config remote.up.url .. &&
127 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
130 echo "$the_commit commit refs/remotes/origin/master" >expect &&
131 git for-each-ref refs/remotes/origin >actual &&
132 test_cmp expect actual
136 test_expect_success
'fetch with insteadOf' '
141 git config "url.$TRASH.insteadOf" trash/ &&
142 git config remote.up.url trash/. &&
143 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
146 echo "$the_commit commit refs/remotes/origin/master" >expect &&
147 git for-each-ref refs/remotes/origin >actual &&
148 test_cmp expect actual
152 test_expect_success
'fetch with pushInsteadOf (should not rewrite)' '
157 git config "url.trash/.pushInsteadOf" "$TRASH" &&
158 git config remote.up.url "$TRASH." &&
159 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
162 echo "$the_commit commit refs/remotes/origin/master" >expect &&
163 git for-each-ref refs/remotes/origin >actual &&
164 test_cmp expect actual
168 test_expect_success
'push without wildcard' '
171 git push testrepo refs/heads/master:refs/remotes/origin/master &&
174 echo "$the_commit commit refs/remotes/origin/master" >expect &&
175 git for-each-ref refs/remotes/origin >actual &&
176 test_cmp expect actual
180 test_expect_success
'push with wildcard' '
183 git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
186 echo "$the_commit commit refs/remotes/origin/master" >expect &&
187 git for-each-ref refs/remotes/origin >actual &&
188 test_cmp expect actual
192 test_expect_success
'push with insteadOf' '
195 test_config "url.$TRASH.insteadOf" trash/ &&
196 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
199 echo "$the_commit commit refs/remotes/origin/master" >expect &&
200 git for-each-ref refs/remotes/origin >actual &&
201 test_cmp expect actual
205 test_expect_success
'push with pushInsteadOf' '
208 test_config "url.$TRASH.pushInsteadOf" trash/ &&
209 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
212 echo "$the_commit commit refs/remotes/origin/master" >expect &&
213 git for-each-ref refs/remotes/origin >actual &&
214 test_cmp expect actual
218 test_expect_success
'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
220 test_config "url.trash2/.pushInsteadOf" testrepo/ &&
221 test_config "url.trash3/.pusnInsteadOf" trash/wrong &&
222 test_config remote.r.url trash/wrong &&
223 test_config remote.r.pushurl "testrepo/" &&
224 git push r refs/heads/master:refs/remotes/origin/master &&
227 echo "$the_commit commit refs/remotes/origin/master" >expect &&
228 git for-each-ref refs/remotes/origin >actual &&
229 test_cmp expect actual
233 test_expect_success
'push with matching heads' '
235 mk_test heads/master &&
237 check_push_result $the_commit heads/master
241 test_expect_success
'push with matching heads on the command line' '
243 mk_test heads/master &&
244 git push testrepo : &&
245 check_push_result $the_commit heads/master
249 test_expect_success
'failed (non-fast-forward) push with matching heads' '
251 mk_test heads/master &&
252 git push testrepo : &&
253 git commit --amend -massaged &&
254 test_must_fail git push testrepo &&
255 check_push_result $the_commit heads/master &&
256 git reset --hard $the_commit
260 test_expect_success
'push --force with matching heads' '
262 mk_test heads/master &&
263 git push testrepo : &&
264 git commit --amend -massaged &&
265 git push --force testrepo &&
266 ! check_push_result $the_commit heads/master &&
267 git reset --hard $the_commit
271 test_expect_success
'push with matching heads and forced update' '
273 mk_test heads/master &&
274 git push testrepo : &&
275 git commit --amend -massaged &&
276 git push testrepo +: &&
277 ! check_push_result $the_commit heads/master &&
278 git reset --hard $the_commit
282 test_expect_success
'push with no ambiguity (1)' '
284 mk_test heads/master &&
285 git push testrepo master:master &&
286 check_push_result $the_commit heads/master
290 test_expect_success
'push with no ambiguity (2)' '
292 mk_test remotes/origin/master &&
293 git push testrepo master:origin/master &&
294 check_push_result $the_commit remotes/origin/master
298 test_expect_success
'push with colon-less refspec, no ambiguity' '
300 mk_test heads/master heads/t/master &&
301 git branch -f t/master master &&
302 git push testrepo master &&
303 check_push_result $the_commit heads/master &&
304 check_push_result $the_first_commit heads/t/master
308 test_expect_success
'push with weak ambiguity (1)' '
310 mk_test heads/master remotes/origin/master &&
311 git push testrepo master:master &&
312 check_push_result $the_commit heads/master &&
313 check_push_result $the_first_commit remotes/origin/master
317 test_expect_success
'push with weak ambiguity (2)' '
319 mk_test heads/master remotes/origin/master remotes/another/master &&
320 git push testrepo master:master &&
321 check_push_result $the_commit heads/master &&
322 check_push_result $the_first_commit remotes/origin/master remotes/another/master
326 test_expect_success
'push with ambiguity' '
328 mk_test heads/frotz tags/frotz &&
329 test_must_fail git push testrepo master:frotz &&
330 check_push_result $the_first_commit heads/frotz tags/frotz
334 test_expect_success
'push with colon-less refspec (1)' '
336 mk_test heads/frotz tags/frotz &&
337 git branch -f frotz master &&
338 git push testrepo frotz &&
339 check_push_result $the_commit heads/frotz &&
340 check_push_result $the_first_commit tags/frotz
344 test_expect_success
'push with colon-less refspec (2)' '
346 mk_test heads/frotz tags/frotz &&
347 if git show-ref --verify -q refs/heads/frotz
352 git push -f testrepo frotz &&
353 check_push_result $the_commit tags/frotz &&
354 check_push_result $the_first_commit heads/frotz
358 test_expect_success
'push with colon-less refspec (3)' '
361 if git show-ref --verify -q refs/tags/frotz
365 git branch -f frotz master &&
366 git push testrepo frotz &&
367 check_push_result $the_commit heads/frotz &&
368 test 1 = $( cd testrepo && git show-ref | wc -l )
371 test_expect_success
'push with colon-less refspec (4)' '
374 if git show-ref --verify -q refs/heads/frotz
379 git push testrepo frotz &&
380 check_push_result $the_commit tags/frotz &&
381 test 1 = $( cd testrepo && git show-ref | wc -l )
385 test_expect_success
'push head with non-existent, incomplete dest' '
388 git push testrepo master:branch &&
389 check_push_result $the_commit heads/branch
393 test_expect_success
'push tag with non-existent, incomplete dest' '
397 git push testrepo v1.0:tag &&
398 check_push_result $the_commit tags/tag
402 test_expect_success
'push sha1 with non-existent, incomplete dest' '
405 test_must_fail git push testrepo `git rev-parse master`:foo
409 test_expect_success
'push ref expression with non-existent, incomplete dest' '
412 test_must_fail git push testrepo master^:branch
416 test_expect_success
'push with HEAD' '
418 mk_test heads/master &&
419 git checkout master &&
420 git push testrepo HEAD &&
421 check_push_result $the_commit heads/master
425 test_expect_success
'push with HEAD nonexisting at remote' '
427 mk_test heads/master &&
428 git checkout -b local master &&
429 git push testrepo HEAD &&
430 check_push_result $the_commit heads/local
433 test_expect_success
'push with +HEAD' '
435 mk_test heads/master &&
436 git checkout master &&
437 git branch -D local &&
438 git checkout -b local &&
439 git push testrepo master local &&
440 check_push_result $the_commit heads/master &&
441 check_push_result $the_commit heads/local &&
443 # Without force rewinding should fail
444 git reset --hard HEAD^ &&
445 test_must_fail git push testrepo HEAD &&
446 check_push_result $the_commit heads/local &&
448 # With force rewinding should succeed
449 git push testrepo +HEAD &&
450 check_push_result $the_first_commit heads/local
454 test_expect_success
'push HEAD with non-existent, incomplete dest' '
457 git checkout master &&
458 git push testrepo HEAD:branch &&
459 check_push_result $the_commit heads/branch
463 test_expect_success
'push with config remote.*.push = HEAD' '
465 mk_test heads/local &&
466 git checkout master &&
467 git branch -f local $the_commit &&
470 git checkout local &&
471 git reset --hard $the_first_commit
473 test_config remote.there.url testrepo &&
474 test_config remote.there.push HEAD &&
475 test_config branch.master.remote there &&
477 check_push_result $the_commit heads/master &&
478 check_push_result $the_first_commit heads/local
481 test_expect_success
'push with config remote.*.pushurl' '
483 mk_test heads/master &&
484 git checkout master &&
485 test_config remote.there.url test2repo &&
486 test_config remote.there.pushurl testrepo &&
488 check_push_result $the_commit heads/master
491 test_expect_success
'push with dry-run' '
493 mk_test heads/master &&
496 old_commit=$(git show-ref -s --verify refs/heads/master)
498 git push --dry-run testrepo &&
499 check_push_result $old_commit heads/master
502 test_expect_success
'push updates local refs' '
504 mk_test heads/master &&
508 git pull .. master &&
510 test $(git rev-parse master) = \
511 $(git rev-parse remotes/origin/master)
516 test_expect_success
'push updates up-to-date local refs' '
518 mk_test heads/master &&
521 (cd child1 && git pull .. master && git push) &&
524 git pull ../child1 master &&
526 test $(git rev-parse master) = \
527 $(git rev-parse remotes/origin/master)
532 test_expect_success
'push preserves up-to-date packed refs' '
534 mk_test heads/master &&
539 ! test -f .git/refs/remotes/origin/master
544 test_expect_success
'push does not update local refs on failure' '
546 mk_test heads/master &&
548 mkdir testrepo/.git/hooks &&
549 echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
550 chmod +x testrepo/.git/hooks/pre-receive &&
554 test_must_fail git push &&
555 test $(git rev-parse master) != \
556 $(git rev-parse remotes/origin/master)
561 test_expect_success
'allow deleting an invalid remote ref' '
563 mk_test heads/master &&
564 rm -f testrepo/.git/objects/??/* &&
565 git push testrepo :refs/heads/master &&
566 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
570 test_expect_success
'pushing valid refs triggers post-receive and post-update hooks' '
571 mk_test_with_hooks heads/master heads/next &&
572 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
573 newmaster=$(git show-ref -s --verify refs/heads/master) &&
574 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
576 git push testrepo refs/heads/master:refs/heads/master :refs/heads/next &&
579 cat >pre-receive.expect <<-EOF &&
580 $orgmaster $newmaster refs/heads/master
581 $orgnext $newnext refs/heads/next
584 cat >update.expect <<-EOF &&
585 refs/heads/master $orgmaster $newmaster
586 refs/heads/next $orgnext $newnext
589 cat >post-receive.expect <<-EOF &&
590 $orgmaster $newmaster refs/heads/master
591 $orgnext $newnext refs/heads/next
594 cat >post-update.expect <<-EOF &&
599 test_cmp pre-receive.expect pre-receive.actual &&
600 test_cmp update.expect update.actual &&
601 test_cmp post-receive.expect post-receive.actual &&
602 test_cmp post-update.expect post-update.actual
606 test_expect_success
'deleting dangling ref triggers hooks with correct args' '
607 mk_test_with_hooks heads/master &&
608 rm -f testrepo/.git/objects/??/* &&
609 git push testrepo :refs/heads/master &&
612 cat >pre-receive.expect <<-EOF &&
613 $_z40 $_z40 refs/heads/master
616 cat >update.expect <<-EOF &&
617 refs/heads/master $_z40 $_z40
620 cat >post-receive.expect <<-EOF &&
621 $_z40 $_z40 refs/heads/master
624 cat >post-update.expect <<-EOF &&
628 test_cmp pre-receive.expect pre-receive.actual &&
629 test_cmp update.expect update.actual &&
630 test_cmp post-receive.expect post-receive.actual &&
631 test_cmp post-update.expect post-update.actual
635 test_expect_success
'deletion of a non-existent ref is not fed to post-receive and post-update hooks' '
636 mk_test_with_hooks heads/master &&
637 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
638 newmaster=$(git show-ref -s --verify refs/heads/master) &&
639 git push testrepo master :refs/heads/nonexistent &&
642 cat >pre-receive.expect <<-EOF &&
643 $orgmaster $newmaster refs/heads/master
644 $_z40 $_z40 refs/heads/nonexistent
647 cat >update.expect <<-EOF &&
648 refs/heads/master $orgmaster $newmaster
649 refs/heads/nonexistent $_z40 $_z40
652 cat >post-receive.expect <<-EOF &&
653 $orgmaster $newmaster refs/heads/master
656 cat >post-update.expect <<-EOF &&
660 test_cmp pre-receive.expect pre-receive.actual &&
661 test_cmp update.expect update.actual &&
662 test_cmp post-receive.expect post-receive.actual &&
663 test_cmp post-update.expect post-update.actual
667 test_expect_success
'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' '
668 mk_test_with_hooks heads/master &&
669 git push testrepo :refs/heads/nonexistent &&
672 cat >pre-receive.expect <<-EOF &&
673 $_z40 $_z40 refs/heads/nonexistent
676 cat >update.expect <<-EOF &&
677 refs/heads/nonexistent $_z40 $_z40
680 test_cmp pre-receive.expect pre-receive.actual &&
681 test_cmp update.expect update.actual &&
682 test_path_is_missing post-receive.actual &&
683 test_path_is_missing post-update.actual
687 test_expect_success
'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' '
688 mk_test_with_hooks heads/master heads/next heads/pu &&
689 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
690 newmaster=$(git show-ref -s --verify refs/heads/master) &&
691 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
693 orgpu=$(cd testrepo && git show-ref -s --verify refs/heads/pu) &&
694 newpu=$(git show-ref -s --verify refs/heads/master) &&
695 git push testrepo refs/heads/master:refs/heads/master \
696 refs/heads/master:refs/heads/pu :refs/heads/next \
697 :refs/heads/nonexistent &&
700 cat >pre-receive.expect <<-EOF &&
701 $orgmaster $newmaster refs/heads/master
702 $orgnext $newnext refs/heads/next
703 $orgpu $newpu refs/heads/pu
704 $_z40 $_z40 refs/heads/nonexistent
707 cat >update.expect <<-EOF &&
708 refs/heads/master $orgmaster $newmaster
709 refs/heads/next $orgnext $newnext
710 refs/heads/pu $orgpu $newpu
711 refs/heads/nonexistent $_z40 $_z40
714 cat >post-receive.expect <<-EOF &&
715 $orgmaster $newmaster refs/heads/master
716 $orgnext $newnext refs/heads/next
717 $orgpu $newpu refs/heads/pu
720 cat >post-update.expect <<-EOF &&
726 test_cmp pre-receive.expect pre-receive.actual &&
727 test_cmp update.expect update.actual &&
728 test_cmp post-receive.expect post-receive.actual &&
729 test_cmp post-update.expect post-update.actual
733 test_expect_success
'allow deleting a ref using --delete' '
734 mk_test heads/master &&
735 (cd testrepo && git config receive.denyDeleteCurrent warn) &&
736 git push testrepo --delete master &&
737 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
740 test_expect_success
'allow deleting a tag using --delete' '
741 mk_test heads/master &&
742 git tag -a -m dummy_message deltag heads/master &&
743 git push testrepo --tags &&
744 (cd testrepo && git rev-parse --verify -q refs/tags/deltag) &&
745 git push testrepo --delete tag deltag &&
746 (cd testrepo && test_must_fail git rev-parse --verify refs/tags/deltag)
749 test_expect_success
'push --delete without args aborts' '
750 mk_test heads/master &&
751 test_must_fail git push testrepo --delete
754 test_expect_success
'push --delete refuses src:dest refspecs' '
755 mk_test heads/master &&
756 test_must_fail git push testrepo --delete master:foo
759 test_expect_success
'warn on push to HEAD of non-bare repository' '
760 mk_test heads/master &&
763 git checkout master &&
764 git config receive.denyCurrentBranch warn
766 git push testrepo master 2>stderr &&
767 grep "warning: updating the current branch" stderr
770 test_expect_success
'deny push to HEAD of non-bare repository' '
771 mk_test heads/master &&
774 git checkout master &&
775 git config receive.denyCurrentBranch true
777 test_must_fail git push testrepo master
780 test_expect_success
'allow push to HEAD of bare repository (bare)' '
781 mk_test heads/master &&
784 git checkout master &&
785 git config receive.denyCurrentBranch true &&
786 git config core.bare true
788 git push testrepo master 2>stderr &&
789 ! grep "warning: updating the current branch" stderr
792 test_expect_success
'allow push to HEAD of non-bare repository (config)' '
793 mk_test heads/master &&
796 git checkout master &&
797 git config receive.denyCurrentBranch false
799 git push testrepo master 2>stderr &&
800 ! grep "warning: updating the current branch" stderr
803 test_expect_success
'fetch with branches' '
805 git branch second $the_first_commit &&
806 git checkout second &&
807 echo ".." > testrepo/.git/branches/branch1 &&
811 echo "$the_commit commit refs/heads/branch1" >expect &&
812 git for-each-ref refs/heads >actual &&
813 test_cmp expect actual
818 test_expect_success
'fetch with branches containing #' '
820 echo "..#second" > testrepo/.git/branches/branch2 &&
824 echo "$the_first_commit commit refs/heads/branch2" >expect &&
825 git for-each-ref refs/heads >actual &&
826 test_cmp expect actual
831 test_expect_success
'push with branches' '
833 git checkout second &&
834 echo "testrepo" > .git/branches/branch1 &&
838 echo "$the_first_commit commit refs/heads/master" >expect &&
839 git for-each-ref refs/heads >actual &&
840 test_cmp expect actual
844 test_expect_success
'push with branches containing #' '
846 echo "testrepo#branch3" > .git/branches/branch2 &&
850 echo "$the_first_commit commit refs/heads/branch3" >expect &&
851 git for-each-ref refs/heads >actual &&
852 test_cmp expect actual
857 test_expect_success
'push into aliased refs (consistent)' '
858 mk_test heads/master &&
864 git symbolic-ref refs/heads/bar refs/heads/foo
865 git config receive.denyCurrentBranch false
872 git commit -a -m child2 &&
875 git push ../child1 foo bar
879 test_expect_success
'push into aliased refs (inconsistent)' '
880 mk_test heads/master &&
886 git symbolic-ref refs/heads/bar refs/heads/foo
887 git config receive.denyCurrentBranch false
894 git commit -a -m child2 &&
899 git commit -a -m child2 &&
901 test_must_fail git push ../child1 foo bar 2>stderr &&
902 grep "refusing inconsistent update" stderr
906 test_expect_success
'push requires --force to update lightweight tag' '
907 mk_test heads/master &&
913 git push ../child2 Tag &&
914 git push ../child2 Tag &&
917 git commit -m "file1" &&
919 test_must_fail git push ../child2 Tag &&
920 git push --force ../child2 Tag &&
922 test_must_fail git push ../child2 Tag HEAD~ &&
923 git push --force ../child2 Tag
927 test_expect_success
'push --porcelain' '
929 echo >.git/foo "To testrepo" &&
930 echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
931 echo >>.git/foo "Done" &&
932 git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
935 echo "$the_commit commit refs/remotes/origin/master" >expect &&
936 git for-each-ref refs/remotes/origin >actual &&
937 test_cmp expect actual
939 test_cmp .git/foo .git/bar
942 test_expect_success
'push --porcelain bad url' '
944 test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
945 test_must_fail grep -q Done .git/bar
948 test_expect_success
'push --porcelain rejected' '
950 git push testrepo refs/heads/master:refs/remotes/origin/master &&
952 git reset --hard origin/master^
953 git config receive.denyCurrentBranch true) &&
955 echo >.git/foo "To testrepo" &&
956 echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
958 test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
959 test_cmp .git/foo .git/bar
962 test_expect_success
'push --porcelain --dry-run rejected' '
964 git push testrepo refs/heads/master:refs/remotes/origin/master &&
966 git reset --hard origin/master
967 git config receive.denyCurrentBranch true) &&
969 echo >.git/foo "To testrepo" &&
970 echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" &&
971 echo >>.git/foo "Done" &&
973 test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master &&
974 test_cmp .git/foo .git/bar
977 test_expect_success
'push --prune' '
978 mk_test heads/master heads/second heads/foo heads/bar &&
979 git push --prune testrepo &&
980 check_push_result $the_commit heads/master &&
981 check_push_result $the_first_commit heads/second &&
982 ! check_push_result $the_first_commit heads/foo heads/bar
985 test_expect_success
'push --prune refspec' '
986 mk_test tmp/master tmp/second tmp/foo tmp/bar &&
987 git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
988 check_push_result $the_commit tmp/master &&
989 check_push_result $the_first_commit tmp/second &&
990 ! check_push_result $the_first_commit tmp/foo tmp/bar
993 for configsection
in transfer receive
995 test_expect_success
"push to update a ref hidden by $configsection.hiderefs" '
996 mk_test heads/master hidden/one hidden/two hidden/three &&
999 git config $configsection.hiderefs refs/hidden
1002 # push to unhidden ref succeeds normally
1003 git push testrepo master:refs/heads/master &&
1004 check_push_result $the_commit heads/master &&
1006 # push to update a hidden ref should fail
1007 test_must_fail git push testrepo master:refs/hidden/one &&
1008 check_push_result $the_first_commit hidden/one &&
1010 # push to delete a hidden ref should fail
1011 test_must_fail git push testrepo :refs/hidden/two &&
1012 check_push_result $the_first_commit hidden/two &&
1014 # idempotent push to update a hidden ref should fail
1015 test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
1016 check_push_result $the_first_commit hidden/three
1020 test_expect_success
'fetch exact SHA1' '
1021 mk_test heads/master hidden/one &&
1022 git push testrepo master:refs/hidden/one &&
1025 git config transfer.hiderefs refs/hidden
1027 check_push_result $the_commit hidden/one &&
1033 # make sure $the_commit does not exist here
1036 test_must_fail git cat-file -t $the_commit &&
1038 # fetching the hidden object should fail by default
1039 test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1040 test_must_fail git rev-parse --verify refs/heads/copy &&
1042 # the server side can allow it to succeed
1045 git config uploadpack.allowtipsha1inwant true
1048 git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1049 result=$(git rev-parse --verify refs/heads/copy) &&
1050 test "$the_commit" = "$result"
1054 test_expect_success
'fetch follows tags by default' '
1055 mk_test heads/master &&
1060 git pull ../testrepo master &&
1061 git tag -m "annotated" tag &&
1062 git for-each-ref >tmp1 &&
1065 sed -n "s|refs/heads/master$|refs/remotes/origin/master|p" tmp1
1067 sort -k 3 >../expect
1072 git remote add origin ../src &&
1073 git config branch.master.remote origin &&
1074 git config branch.master.merge refs/heads/master &&
1076 git for-each-ref >../actual
1078 test_cmp expect actual
1081 test_expect_success
'push does not follow tags by default' '
1082 mk_test heads/master &&
1085 git init --bare dst &&
1088 git pull ../testrepo master &&
1089 git tag -m "annotated" tag &&
1090 git checkout -b another &&
1091 git commit --allow-empty -m "future commit" &&
1092 git tag -m "future" future &&
1093 git checkout master &&
1094 git for-each-ref refs/heads/master >../expect &&
1095 git push ../dst master
1099 git for-each-ref >../actual
1101 test_cmp expect actual
1104 test_expect_success
'push --follow-tag only pushes relevant tags' '
1105 mk_test heads/master &&
1108 git init --bare dst &&
1111 git pull ../testrepo master &&
1112 git tag -m "annotated" tag &&
1113 git checkout -b another &&
1114 git commit --allow-empty -m "future commit" &&
1115 git tag -m "future" future &&
1116 git checkout master &&
1117 git for-each-ref refs/heads/master refs/tags/tag >../expect
1118 git push --follow-tag ../dst master
1122 git for-each-ref >../actual
1124 test_cmp expect actual