push: also use "upstream" mapping when pushing a single ref
[gitweb.git] / t / t5516-fetch-push.sh
index 6d7f102ca4ed91f11fe769643bd270d89d38f05b..926e7f6b979d4d1c69ecc9d280cd6de365627012 100755 (executable)
@@ -1160,6 +1160,7 @@ test_expect_success 'with no remote.$name.push, it is not used as refmap' '
                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
        ) &&
@@ -1171,6 +1172,35 @@ test_expect_success 'with no remote.$name.push, it is not used as refmap' '
        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 &&