t9001: style modernisation phase #3
[gitweb.git] / t / t5516-fetch-push.sh
index 99c32d75391bb02fae779ad831879903abca5d25..f4da20aa9bf7df1b2ab1fda207b70e1913277603 100755 (executable)
@@ -11,6 +11,7 @@ This test checks the following functionality:
 * hooks
 * --porcelain output format
 * hiderefs
+* reflogs
 '
 
 . ./test-lib.sh
@@ -536,6 +537,19 @@ test_expect_success 'push with config branch.*.pushremote' '
        check_push_result down_repo $the_commit heads/master
 '
 
+test_expect_success 'branch.*.pushremote config order is irrelevant' '
+       mk_test one_repo heads/master &&
+       mk_test two_repo heads/master &&
+       test_config remote.one.url one_repo &&
+       test_config remote.two.url two_repo &&
+       test_config branch.master.pushremote two_repo &&
+       test_config remote.pushdefault one_repo &&
+       test_config push.default matching &&
+       git push &&
+       check_push_result one_repo $the_first_commit heads/master &&
+       check_push_result two_repo $the_commit heads/master
+'
+
 test_expect_success 'push with dry-run' '
 
        mk_test testrepo heads/master &&
@@ -1126,6 +1140,81 @@ test_expect_success 'fetch follows tags by default' '
        test_cmp expect actual
 '
 
+test_expect_success 'pushing a specific ref applies remote.$name.push as refmap' '
+       mk_test testrepo heads/master &&
+       rm -fr src dst &&
+       git init src &&
+       git init --bare dst &&
+       (
+               cd src &&
+               git pull ../testrepo master &&
+               git branch next &&
+               git config remote.dst.url ../dst &&
+               git config remote.dst.push "+refs/heads/*:refs/remotes/src/*" &&
+               git push dst master &&
+               git show-ref refs/heads/master |
+               sed -e "s|refs/heads/|refs/remotes/src/|" >../dst/expect
+       ) &&
+       (
+               cd dst &&
+               test_must_fail git show-ref refs/heads/next &&
+               test_must_fail git show-ref refs/heads/master &&
+               git show-ref refs/remotes/src/master >actual
+       ) &&
+       test_cmp dst/expect dst/actual
+'
+
+test_expect_success 'with no remote.$name.push, it is not used as refmap' '
+       mk_test testrepo heads/master &&
+       rm -fr src dst &&
+       git init src &&
+       git init --bare dst &&
+       (
+               cd src &&
+               git pull ../testrepo master &&
+               git branch next &&
+               git config remote.dst.url ../dst &&
+               git config push.default matching &&
+               git push dst master &&
+               git show-ref refs/heads/master >../dst/expect
+       ) &&
+       (
+               cd dst &&
+               test_must_fail git show-ref refs/heads/next &&
+               git show-ref refs/heads/master >actual
+       ) &&
+       test_cmp dst/expect dst/actual
+'
+
+test_expect_success 'with no remote.$name.push, upstream mapping is used' '
+       mk_test testrepo heads/master &&
+       rm -fr src dst &&
+       git init src &&
+       git init --bare dst &&
+       (
+               cd src &&
+               git pull ../testrepo master &&
+               git branch next &&
+               git config remote.dst.url ../dst &&
+               git config remote.dst.fetch "+refs/heads/*:refs/remotes/dst/*" &&
+               git config push.default upstream &&
+
+               git config branch.master.merge refs/heads/trunk &&
+               git config branch.master.remote dst &&
+
+               git push dst master &&
+               git show-ref refs/heads/master |
+               sed -e "s|refs/heads/master|refs/heads/trunk|" >../dst/expect
+       ) &&
+       (
+               cd dst &&
+               test_must_fail git show-ref refs/heads/master &&
+               test_must_fail git show-ref refs/heads/next &&
+               git show-ref refs/heads/trunk >actual
+       ) &&
+       test_cmp dst/expect dst/actual
+'
+
 test_expect_success 'push does not follow tags by default' '
        mk_test testrepo heads/master &&
        rm -fr src dst &&
@@ -1189,4 +1278,56 @@ EOF
        git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo
 '
 
+test_expect_success 'pushing a tag pushes the tagged object' '
+       rm -rf dst.git &&
+       blob=$(echo unreferenced | git hash-object -w --stdin) &&
+       git tag -m foo tag-of-blob $blob &&
+       git init --bare dst.git &&
+       git push dst.git tag-of-blob &&
+       # the receiving index-pack should have noticed
+       # any problems, but we double check
+       echo unreferenced >expect &&
+       git --git-dir=dst.git cat-file blob tag-of-blob >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'push into bare respects core.logallrefupdates' '
+       rm -rf dst.git &&
+       git init --bare dst.git &&
+       git -C dst.git config core.logallrefupdates true &&
+
+       # double push to test both with and without
+       # the actual pack transfer
+       git push dst.git master:one &&
+       echo "one@{0} push" >expect &&
+       git -C dst.git log -g --format="%gd %gs" one >actual &&
+       test_cmp expect actual &&
+
+       git push dst.git master:two &&
+       echo "two@{0} push" >expect &&
+       git -C dst.git log -g --format="%gd %gs" two >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'fetch into bare respects core.logallrefupdates' '
+       rm -rf dst.git &&
+       git init --bare dst.git &&
+       (
+               cd dst.git &&
+               git config core.logallrefupdates true &&
+
+               # as above, we double-fetch to test both
+               # with and without pack transfer
+               git fetch .. master:one &&
+               echo "one@{0} fetch .. master:one: storing head" >expect &&
+               git log -g --format="%gd %gs" one >actual &&
+               test_cmp expect actual &&
+
+               git fetch .. master:two &&
+               echo "two@{0} fetch .. master:two: storing head" >expect &&
+               git log -g --format="%gd %gs" two >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done