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
26 git config receive.denyCurrentBranch warn
&&
27 mv .git
/hooks .git
/hooks-disabled
36 git push testrepo
$the_first_commit:refs
/$ref ||
42 echo "$the_first_commit" >expect
&&
43 git show-ref
-s --verify refs
/$ref >actual
&&
44 test_cmp expect actual ||
51 mk_test_with_hooks
() {
58 cat >pre-receive
<<-'EOF' &&
60 cat - >>pre-receive.actual
63 cat >update
<<-'EOF' &&
65 printf "%s %s %s\n" "$@" >>update.actual
68 cat >post-receive
<<-'EOF' &&
70 cat - >>post-receive.actual
73 cat >post-update
<<-'EOF' &&
77 printf "%s\n" "$ref" >>post-update.actual
81 chmod +x pre-receive update post-receive post-update
87 git clone testrepo
"$1"
90 check_push_result
() {
97 git show-ref
-s --verify refs
/$ref >actual
&&
98 test_cmp expect actual ||
105 test_expect_success setup
'
110 git commit -a -m repo &&
111 the_first_commit=$(git show-ref -s --verify refs/heads/master) &&
116 git commit -a -m second &&
117 the_commit=$(git show-ref -s --verify refs/heads/master)
121 test_expect_success
'fetch without wildcard' '
125 git fetch .. refs/heads/master:refs/remotes/origin/master &&
127 echo "$the_commit commit refs/remotes/origin/master" >expect &&
128 git for-each-ref refs/remotes/origin >actual &&
129 test_cmp expect actual
133 test_expect_success
'fetch with wildcard' '
137 git config remote.up.url .. &&
138 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
141 echo "$the_commit commit refs/remotes/origin/master" >expect &&
142 git for-each-ref refs/remotes/origin >actual &&
143 test_cmp expect actual
147 test_expect_success
'fetch with insteadOf' '
152 git config "url.$TRASH.insteadOf" trash/ &&
153 git config remote.up.url trash/. &&
154 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
157 echo "$the_commit commit refs/remotes/origin/master" >expect &&
158 git for-each-ref refs/remotes/origin >actual &&
159 test_cmp expect actual
163 test_expect_success
'fetch with pushInsteadOf (should not rewrite)' '
168 git config "url.trash/.pushInsteadOf" "$TRASH" &&
169 git config remote.up.url "$TRASH." &&
170 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
173 echo "$the_commit commit refs/remotes/origin/master" >expect &&
174 git for-each-ref refs/remotes/origin >actual &&
175 test_cmp expect actual
179 test_expect_success
'push without wildcard' '
182 git push testrepo refs/heads/master:refs/remotes/origin/master &&
185 echo "$the_commit commit refs/remotes/origin/master" >expect &&
186 git for-each-ref refs/remotes/origin >actual &&
187 test_cmp expect actual
191 test_expect_success
'push with wildcard' '
194 git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
197 echo "$the_commit commit refs/remotes/origin/master" >expect &&
198 git for-each-ref refs/remotes/origin >actual &&
199 test_cmp expect actual
203 test_expect_success
'push with insteadOf' '
206 test_config "url.$TRASH.insteadOf" trash/ &&
207 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
210 echo "$the_commit commit refs/remotes/origin/master" >expect &&
211 git for-each-ref refs/remotes/origin >actual &&
212 test_cmp expect actual
216 test_expect_success
'push with pushInsteadOf' '
219 test_config "url.$TRASH.pushInsteadOf" trash/ &&
220 git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
223 echo "$the_commit commit refs/remotes/origin/master" >expect &&
224 git for-each-ref refs/remotes/origin >actual &&
225 test_cmp expect actual
229 test_expect_success
'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
232 test_config "url.trash2/.pushInsteadOf" trash/ &&
233 test_config remote.r.url trash/wrong &&
234 test_config remote.r.pushurl "$TRASH/testrepo" &&
235 git push r refs/heads/master:refs/remotes/origin/master &&
238 echo "$the_commit commit refs/remotes/origin/master" >expect &&
239 git for-each-ref refs/remotes/origin >actual &&
240 test_cmp expect actual
244 test_expect_success
'push with matching heads' '
246 mk_test heads/master &&
248 check_push_result $the_commit heads/master
252 test_expect_success
'push with matching heads on the command line' '
254 mk_test heads/master &&
255 git push testrepo : &&
256 check_push_result $the_commit heads/master
260 test_expect_success
'failed (non-fast-forward) push with matching heads' '
262 mk_test heads/master &&
263 git push testrepo : &&
264 git commit --amend -massaged &&
265 test_must_fail git push testrepo &&
266 check_push_result $the_commit heads/master &&
267 git reset --hard $the_commit
271 test_expect_success
'push --force with matching heads' '
273 mk_test heads/master &&
274 git push testrepo : &&
275 git commit --amend -massaged &&
276 git push --force testrepo &&
277 ! check_push_result $the_commit heads/master &&
278 git reset --hard $the_commit
282 test_expect_success
'push with matching heads and forced update' '
284 mk_test heads/master &&
285 git push testrepo : &&
286 git commit --amend -massaged &&
287 git push testrepo +: &&
288 ! check_push_result $the_commit heads/master &&
289 git reset --hard $the_commit
293 test_expect_success
'push with no ambiguity (1)' '
295 mk_test heads/master &&
296 git push testrepo master:master &&
297 check_push_result $the_commit heads/master
301 test_expect_success
'push with no ambiguity (2)' '
303 mk_test remotes/origin/master &&
304 git push testrepo master:origin/master &&
305 check_push_result $the_commit remotes/origin/master
309 test_expect_success
'push with colon-less refspec, no ambiguity' '
311 mk_test heads/master heads/t/master &&
312 git branch -f t/master master &&
313 git push testrepo master &&
314 check_push_result $the_commit heads/master &&
315 check_push_result $the_first_commit heads/t/master
319 test_expect_success
'push with weak ambiguity (1)' '
321 mk_test heads/master remotes/origin/master &&
322 git push testrepo master:master &&
323 check_push_result $the_commit heads/master &&
324 check_push_result $the_first_commit remotes/origin/master
328 test_expect_success
'push with weak ambiguity (2)' '
330 mk_test heads/master remotes/origin/master remotes/another/master &&
331 git push testrepo master:master &&
332 check_push_result $the_commit heads/master &&
333 check_push_result $the_first_commit remotes/origin/master remotes/another/master
337 test_expect_success
'push with ambiguity' '
339 mk_test heads/frotz tags/frotz &&
340 test_must_fail git push testrepo master:frotz &&
341 check_push_result $the_first_commit heads/frotz tags/frotz
345 test_expect_success
'push with colon-less refspec (1)' '
347 mk_test heads/frotz tags/frotz &&
348 git branch -f frotz master &&
349 git push testrepo frotz &&
350 check_push_result $the_commit heads/frotz &&
351 check_push_result $the_first_commit tags/frotz
355 test_expect_success
'push with colon-less refspec (2)' '
357 mk_test heads/frotz tags/frotz &&
358 if git show-ref --verify -q refs/heads/frotz
363 git push -f testrepo frotz &&
364 check_push_result $the_commit tags/frotz &&
365 check_push_result $the_first_commit heads/frotz
369 test_expect_success
'push with colon-less refspec (3)' '
372 if git show-ref --verify -q refs/tags/frotz
376 git branch -f frotz master &&
377 git push testrepo frotz &&
378 check_push_result $the_commit heads/frotz &&
379 test 1 = $( cd testrepo && git show-ref | wc -l )
382 test_expect_success
'push with colon-less refspec (4)' '
385 if git show-ref --verify -q refs/heads/frotz
390 git push testrepo frotz &&
391 check_push_result $the_commit tags/frotz &&
392 test 1 = $( cd testrepo && git show-ref | wc -l )
396 test_expect_success
'push head with non-existent, incomplete dest' '
399 git push testrepo master:branch &&
400 check_push_result $the_commit heads/branch
404 test_expect_success
'push tag with non-existent, incomplete dest' '
408 git push testrepo v1.0:tag &&
409 check_push_result $the_commit tags/tag
413 test_expect_success
'push sha1 with non-existent, incomplete dest' '
416 test_must_fail git push testrepo `git rev-parse master`:foo
420 test_expect_success
'push ref expression with non-existent, incomplete dest' '
423 test_must_fail git push testrepo master^:branch
427 test_expect_success
'push with HEAD' '
429 mk_test heads/master &&
430 git checkout master &&
431 git push testrepo HEAD &&
432 check_push_result $the_commit heads/master
436 test_expect_success
'push with HEAD nonexisting at remote' '
438 mk_test heads/master &&
439 git checkout -b local master &&
440 git push testrepo HEAD &&
441 check_push_result $the_commit heads/local
444 test_expect_success
'push with +HEAD' '
446 mk_test heads/master &&
447 git checkout master &&
448 git branch -D local &&
449 git checkout -b local &&
450 git push testrepo master local &&
451 check_push_result $the_commit heads/master &&
452 check_push_result $the_commit heads/local &&
454 # Without force rewinding should fail
455 git reset --hard HEAD^ &&
456 test_must_fail git push testrepo HEAD &&
457 check_push_result $the_commit heads/local &&
459 # With force rewinding should succeed
460 git push testrepo +HEAD &&
461 check_push_result $the_first_commit heads/local
465 test_expect_success
'push HEAD with non-existent, incomplete dest' '
468 git checkout master &&
469 git push testrepo HEAD:branch &&
470 check_push_result $the_commit heads/branch
474 test_expect_success
'push with config remote.*.push = HEAD' '
476 mk_test heads/local &&
477 git checkout master &&
478 git branch -f local $the_commit &&
481 git checkout local &&
482 git reset --hard $the_first_commit
484 test_config remote.there.url testrepo &&
485 test_config remote.there.push HEAD &&
486 test_config branch.master.remote there &&
488 check_push_result $the_commit heads/master &&
489 check_push_result $the_first_commit heads/local
492 test_expect_success
'push with config remote.*.pushurl' '
494 mk_test heads/master &&
495 git checkout master &&
496 test_config remote.there.url test2repo &&
497 test_config remote.there.pushurl testrepo &&
499 check_push_result $the_commit heads/master
502 test_expect_success
'push with dry-run' '
504 mk_test heads/master &&
507 old_commit=$(git show-ref -s --verify refs/heads/master)
509 git push --dry-run testrepo &&
510 check_push_result $old_commit heads/master
513 test_expect_success
'push updates local refs' '
515 mk_test heads/master &&
519 git pull .. master &&
521 test $(git rev-parse master) = \
522 $(git rev-parse remotes/origin/master)
527 test_expect_success
'push updates up-to-date local refs' '
529 mk_test heads/master &&
532 (cd child1 && git pull .. master && git push) &&
535 git pull ../child1 master &&
537 test $(git rev-parse master) = \
538 $(git rev-parse remotes/origin/master)
543 test_expect_success
'push preserves up-to-date packed refs' '
545 mk_test heads/master &&
550 ! test -f .git/refs/remotes/origin/master
555 test_expect_success
'push does not update local refs on failure' '
557 mk_test heads/master &&
559 mkdir testrepo/.git/hooks &&
560 echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
561 chmod +x testrepo/.git/hooks/pre-receive &&
565 test_must_fail git push &&
566 test $(git rev-parse master) != \
567 $(git rev-parse remotes/origin/master)
572 test_expect_success
'allow deleting an invalid remote ref' '
574 mk_test heads/master &&
575 rm -f testrepo/.git/objects/??/* &&
576 git push testrepo :refs/heads/master &&
577 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
581 test_expect_success
'pushing valid refs triggers post-receive and post-update hooks' '
582 mk_test_with_hooks heads/master heads/next &&
583 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
584 newmaster=$(git show-ref -s --verify refs/heads/master) &&
585 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
587 git push testrepo refs/heads/master:refs/heads/master :refs/heads/next &&
590 cat >pre-receive.expect <<-EOF &&
591 $orgmaster $newmaster refs/heads/master
592 $orgnext $newnext refs/heads/next
595 cat >update.expect <<-EOF &&
596 refs/heads/master $orgmaster $newmaster
597 refs/heads/next $orgnext $newnext
600 cat >post-receive.expect <<-EOF &&
601 $orgmaster $newmaster refs/heads/master
602 $orgnext $newnext refs/heads/next
605 cat >post-update.expect <<-EOF &&
610 test_cmp pre-receive.expect pre-receive.actual &&
611 test_cmp update.expect update.actual &&
612 test_cmp post-receive.expect post-receive.actual &&
613 test_cmp post-update.expect post-update.actual
617 test_expect_success
'deleting dangling ref triggers hooks with correct args' '
618 mk_test_with_hooks heads/master &&
619 rm -f testrepo/.git/objects/??/* &&
620 git push testrepo :refs/heads/master &&
623 cat >pre-receive.expect <<-EOF &&
624 $_z40 $_z40 refs/heads/master
627 cat >update.expect <<-EOF &&
628 refs/heads/master $_z40 $_z40
631 cat >post-receive.expect <<-EOF &&
632 $_z40 $_z40 refs/heads/master
635 cat >post-update.expect <<-EOF &&
639 test_cmp pre-receive.expect pre-receive.actual &&
640 test_cmp update.expect update.actual &&
641 test_cmp post-receive.expect post-receive.actual &&
642 test_cmp post-update.expect post-update.actual
646 test_expect_success
'deletion of a non-existent ref is not fed to post-receive and post-update hooks' '
647 mk_test_with_hooks heads/master &&
648 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
649 newmaster=$(git show-ref -s --verify refs/heads/master) &&
650 git push testrepo master :refs/heads/nonexistent &&
653 cat >pre-receive.expect <<-EOF &&
654 $orgmaster $newmaster refs/heads/master
655 $_z40 $_z40 refs/heads/nonexistent
658 cat >update.expect <<-EOF &&
659 refs/heads/master $orgmaster $newmaster
660 refs/heads/nonexistent $_z40 $_z40
663 cat >post-receive.expect <<-EOF &&
664 $orgmaster $newmaster refs/heads/master
667 cat >post-update.expect <<-EOF &&
671 test_cmp pre-receive.expect pre-receive.actual &&
672 test_cmp update.expect update.actual &&
673 test_cmp post-receive.expect post-receive.actual &&
674 test_cmp post-update.expect post-update.actual
678 test_expect_success
'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' '
679 mk_test_with_hooks heads/master &&
680 git push testrepo :refs/heads/nonexistent &&
683 cat >pre-receive.expect <<-EOF &&
684 $_z40 $_z40 refs/heads/nonexistent
687 cat >update.expect <<-EOF &&
688 refs/heads/nonexistent $_z40 $_z40
691 test_cmp pre-receive.expect pre-receive.actual &&
692 test_cmp update.expect update.actual &&
693 test_path_is_missing post-receive.actual &&
694 test_path_is_missing post-update.actual
698 test_expect_success
'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' '
699 mk_test_with_hooks heads/master heads/next heads/pu &&
700 orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
701 newmaster=$(git show-ref -s --verify refs/heads/master) &&
702 orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
704 orgpu=$(cd testrepo && git show-ref -s --verify refs/heads/pu) &&
705 newpu=$(git show-ref -s --verify refs/heads/master) &&
706 git push testrepo refs/heads/master:refs/heads/master \
707 refs/heads/master:refs/heads/pu :refs/heads/next \
708 :refs/heads/nonexistent &&
711 cat >pre-receive.expect <<-EOF &&
712 $orgmaster $newmaster refs/heads/master
713 $orgnext $newnext refs/heads/next
714 $orgpu $newpu refs/heads/pu
715 $_z40 $_z40 refs/heads/nonexistent
718 cat >update.expect <<-EOF &&
719 refs/heads/master $orgmaster $newmaster
720 refs/heads/next $orgnext $newnext
721 refs/heads/pu $orgpu $newpu
722 refs/heads/nonexistent $_z40 $_z40
725 cat >post-receive.expect <<-EOF &&
726 $orgmaster $newmaster refs/heads/master
727 $orgnext $newnext refs/heads/next
728 $orgpu $newpu refs/heads/pu
731 cat >post-update.expect <<-EOF &&
737 test_cmp pre-receive.expect pre-receive.actual &&
738 test_cmp update.expect update.actual &&
739 test_cmp post-receive.expect post-receive.actual &&
740 test_cmp post-update.expect post-update.actual
744 test_expect_success
'allow deleting a ref using --delete' '
745 mk_test heads/master &&
746 (cd testrepo && git config receive.denyDeleteCurrent warn) &&
747 git push testrepo --delete master &&
748 (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
751 test_expect_success
'allow deleting a tag using --delete' '
752 mk_test heads/master &&
753 git tag -a -m dummy_message deltag heads/master &&
754 git push testrepo --tags &&
755 (cd testrepo && git rev-parse --verify -q refs/tags/deltag) &&
756 git push testrepo --delete tag deltag &&
757 (cd testrepo && test_must_fail git rev-parse --verify refs/tags/deltag)
760 test_expect_success
'push --delete without args aborts' '
761 mk_test heads/master &&
762 test_must_fail git push testrepo --delete
765 test_expect_success
'push --delete refuses src:dest refspecs' '
766 mk_test heads/master &&
767 test_must_fail git push testrepo --delete master:foo
770 test_expect_success
'warn on push to HEAD of non-bare repository' '
771 mk_test heads/master &&
774 git checkout master &&
775 git config receive.denyCurrentBranch warn
777 git push testrepo master 2>stderr &&
778 grep "warning: updating the current branch" stderr
781 test_expect_success
'deny push to HEAD of non-bare repository' '
782 mk_test heads/master &&
785 git checkout master &&
786 git config receive.denyCurrentBranch true
788 test_must_fail git push testrepo master
791 test_expect_success
'allow push to HEAD of bare repository (bare)' '
792 mk_test heads/master &&
795 git checkout master &&
796 git config receive.denyCurrentBranch true &&
797 git config core.bare true
799 git push testrepo master 2>stderr &&
800 ! grep "warning: updating the current branch" stderr
803 test_expect_success
'allow push to HEAD of non-bare repository (config)' '
804 mk_test heads/master &&
807 git checkout master &&
808 git config receive.denyCurrentBranch false
810 git push testrepo master 2>stderr &&
811 ! grep "warning: updating the current branch" stderr
814 test_expect_success
'fetch with branches' '
816 git branch second $the_first_commit &&
817 git checkout second &&
818 echo ".." > testrepo/.git/branches/branch1 &&
822 echo "$the_commit commit refs/heads/branch1" >expect &&
823 git for-each-ref refs/heads >actual &&
824 test_cmp expect actual
829 test_expect_success
'fetch with branches containing #' '
831 echo "..#second" > testrepo/.git/branches/branch2 &&
835 echo "$the_first_commit commit refs/heads/branch2" >expect &&
836 git for-each-ref refs/heads >actual &&
837 test_cmp expect actual
842 test_expect_success
'push with branches' '
844 git checkout second &&
845 echo "testrepo" > .git/branches/branch1 &&
849 echo "$the_first_commit commit refs/heads/master" >expect &&
850 git for-each-ref refs/heads >actual &&
851 test_cmp expect actual
855 test_expect_success
'push with branches containing #' '
857 echo "testrepo#branch3" > .git/branches/branch2 &&
861 echo "$the_first_commit commit refs/heads/branch3" >expect &&
862 git for-each-ref refs/heads >actual &&
863 test_cmp expect actual
868 test_expect_success
'push into aliased refs (consistent)' '
869 mk_test heads/master &&
875 git symbolic-ref refs/heads/bar refs/heads/foo
876 git config receive.denyCurrentBranch false
883 git commit -a -m child2 &&
886 git push ../child1 foo bar
890 test_expect_success
'push into aliased refs (inconsistent)' '
891 mk_test heads/master &&
897 git symbolic-ref refs/heads/bar refs/heads/foo
898 git config receive.denyCurrentBranch false
905 git commit -a -m child2 &&
910 git commit -a -m child2 &&
912 test_must_fail git push ../child1 foo bar 2>stderr &&
913 grep "refusing inconsistent update" stderr
917 test_expect_success
'push requires --force to update lightweight tag' '
918 mk_test heads/master &&
924 git push ../child2 Tag &&
925 git push ../child2 Tag &&
928 git commit -m "file1" &&
930 test_must_fail git push ../child2 Tag &&
931 git push --force ../child2 Tag &&
933 test_must_fail git push ../child2 Tag HEAD~ &&
934 git push --force ../child2 Tag
938 test_expect_success
'push --porcelain' '
940 echo >.git/foo "To testrepo" &&
941 echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
942 echo >>.git/foo "Done" &&
943 git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
946 echo "$the_commit commit refs/remotes/origin/master" >expect &&
947 git for-each-ref refs/remotes/origin >actual &&
948 test_cmp expect actual
950 test_cmp .git/foo .git/bar
953 test_expect_success
'push --porcelain bad url' '
955 test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
956 test_must_fail grep -q Done .git/bar
959 test_expect_success
'push --porcelain rejected' '
961 git push testrepo refs/heads/master:refs/remotes/origin/master &&
963 git reset --hard origin/master^
964 git config receive.denyCurrentBranch true) &&
966 echo >.git/foo "To testrepo" &&
967 echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
969 test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
970 test_cmp .git/foo .git/bar
973 test_expect_success
'push --porcelain --dry-run rejected' '
975 git push testrepo refs/heads/master:refs/remotes/origin/master &&
977 git reset --hard origin/master
978 git config receive.denyCurrentBranch true) &&
980 echo >.git/foo "To testrepo" &&
981 echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" &&
982 echo >>.git/foo "Done" &&
984 test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master &&
985 test_cmp .git/foo .git/bar
988 test_expect_success
'push --prune' '
989 mk_test heads/master heads/second heads/foo heads/bar &&
990 git push --prune testrepo &&
991 check_push_result $the_commit heads/master &&
992 check_push_result $the_first_commit heads/second &&
993 ! check_push_result $the_first_commit heads/foo heads/bar
996 test_expect_success
'push --prune refspec' '
997 mk_test tmp/master tmp/second tmp/foo tmp/bar &&
998 git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
999 check_push_result $the_commit tmp/master &&
1000 check_push_result $the_first_commit tmp/second &&
1001 ! check_push_result $the_first_commit tmp/foo tmp/bar
1004 for configsection
in transfer receive
1006 test_expect_success
"push to update a ref hidden by $configsection.hiderefs" '
1007 mk_test heads/master hidden/one hidden/two hidden/three &&
1010 git config $configsection.hiderefs refs/hidden
1013 # push to unhidden ref succeeds normally
1014 git push testrepo master:refs/heads/master &&
1015 check_push_result $the_commit heads/master &&
1017 # push to update a hidden ref should fail
1018 test_must_fail git push testrepo master:refs/hidden/one &&
1019 check_push_result $the_first_commit hidden/one &&
1021 # push to delete a hidden ref should fail
1022 test_must_fail git push testrepo :refs/hidden/two &&
1023 check_push_result $the_first_commit hidden/two &&
1025 # idempotent push to update a hidden ref should fail
1026 test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
1027 check_push_result $the_first_commit hidden/three
1031 test_expect_success
'fetch exact SHA1' '
1032 mk_test heads/master hidden/one &&
1033 git push testrepo master:refs/hidden/one &&
1036 git config transfer.hiderefs refs/hidden
1038 check_push_result $the_commit hidden/one &&
1044 # make sure $the_commit does not exist here
1047 test_must_fail git cat-file -t $the_commit &&
1049 # fetching the hidden object should fail by default
1050 test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1051 test_must_fail git rev-parse --verify refs/heads/copy &&
1053 # the server side can allow it to succeed
1056 git config uploadpack.allowtipsha1inwant true
1059 git fetch -v ../testrepo $the_commit:refs/heads/copy &&
1060 result=$(git rev-parse --verify refs/heads/copy) &&
1061 test "$the_commit" = "$result"
1065 test_expect_success
'fetch follows tags by default' '
1066 mk_test heads/master &&
1071 git pull ../testrepo master &&
1072 git tag -m "annotated" tag &&
1073 git for-each-ref >tmp1 &&
1076 sed -n "s|refs/heads/master$|refs/remotes/origin/master|p" tmp1
1078 sort -k 3 >../expect
1083 git remote add origin ../src &&
1084 git config branch.master.remote origin &&
1085 git config branch.master.merge refs/heads/master &&
1087 git for-each-ref >../actual
1089 test_cmp expect actual
1092 test_expect_success
'push does not follow tags by default' '
1093 mk_test heads/master &&
1096 git init --bare dst &&
1099 git pull ../testrepo master &&
1100 git tag -m "annotated" tag &&
1101 git checkout -b another &&
1102 git commit --allow-empty -m "future commit" &&
1103 git tag -m "future" future &&
1104 git checkout master &&
1105 git for-each-ref refs/heads/master >../expect &&
1106 git push ../dst master
1110 git for-each-ref >../actual
1112 test_cmp expect actual
1115 test_expect_success
'push --follow-tag only pushes relevant tags' '
1116 mk_test heads/master &&
1119 git init --bare dst &&
1122 git pull ../testrepo master &&
1123 git tag -m "annotated" tag &&
1124 git checkout -b another &&
1125 git commit --allow-empty -m "future commit" &&
1126 git tag -m "future" future &&
1127 git checkout master &&
1128 git for-each-ref refs/heads/master refs/tags/tag >../expect
1129 git push --follow-tag ../dst master
1133 git for-each-ref >../actual
1135 test_cmp expect actual