Merge branch 'rr/triangle'
authorJunio C Hamano <gitster@pobox.com>
Sun, 7 Apr 2013 21:32:50 +0000 (14:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Apr 2013 21:32:50 +0000 (14:32 -0700)
Support "pull from one place, push to another place" workflow
better by introducing remote.pushdefault (overrides the "origin"
thing) and branch.*.pushremote (overrides the branch.*.remote).

* rr/triangle:
remote.c: introduce branch.<name>.pushremote
remote.c: introduce remote.pushdefault
remote.c: introduce a way to have different remotes for fetch/push
t5516 (fetch-push): drop implicit arguments from helper functions
t5516 (fetch-push): update test description
remote.c: simplify a bit of code using git_config_string()

Documentation/config.txt
builtin/push.c
remote.c
remote.h
t/t5516-fetch-push.sh
index f79184c0a83170ea54298f2b8ac960372371b0f3..3d750e0452308a4d3bf15053bfc5131d43c8c913 100644 (file)
@@ -727,9 +727,22 @@ branch.autosetuprebase::
        This option defaults to never.
 
 branch.<name>.remote::
-       When in branch <name>, it tells 'git fetch' and 'git push' which
-       remote to fetch from/push to.  It defaults to `origin` if no remote is
-       configured. `origin` is also used if you are not on any branch.
+       When on branch <name>, it tells 'git fetch' and 'git push'
+       which remote to fetch from/push to.  The remote to push to
+       may be overridden with `remote.pushdefault` (for all branches).
+       The remote to push to, for the current branch, may be further
+       overridden by `branch.<name>.pushremote`.  If no remote is
+       configured, or if you are not on any branch, it defaults to
+       `origin` for fetching and `remote.pushdefault` for pushing.
+
+branch.<name>.pushremote::
+       When on branch <name>, it overrides `branch.<name>.remote` for
+       pushing.  It also overrides `remote.pushdefault` for pushing
+       from branch <name>.  When you pull from one place (e.g. your
+       upstream) and push to another place (e.g. your own publishing
+       repository), you would want to set `remote.pushdefault` to
+       specify the remote to push to for all branches, and use this
+       option to override it for a specific branch.
 
 branch.<name>.merge::
        Defines, together with branch.<name>.remote, the upstream branch
@@ -1898,6 +1911,11 @@ receive.updateserverinfo::
        If set to true, git-receive-pack will run git-update-server-info
        after receiving data from git-push and updating refs.
 
+remote.pushdefault::
+       The remote to push to by default.  Overrides
+       `branch.<name>.remote` for all branches, and is overridden by
+       `branch.<name>.pushremote` for specific branches.
+
 remote.<name>.url::
        The URL of a remote repository.  See linkgit:git-fetch[1] or
        linkgit:git-push[1].
index 5e4a0e958f3649c5a5a9f317876e8afd6f6bea6f..909c34dfda984be86fba2013fedc3fdb10b5e2f1 100644 (file)
@@ -322,7 +322,7 @@ static int push_with_options(struct transport *transport, int flags)
 static int do_push(const char *repo, int flags)
 {
        int i, errs;
-       struct remote *remote = remote_get(repo);
+       struct remote *remote = pushremote_get(repo);
        const char **url;
        int url_nr;
 
index ca1edd901e4e64cb497b790f675537283c4ee1c0..68eb99bdf0ca3fedd02ab1bc93db7549b21b62d4 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -49,6 +49,7 @@ static int branches_nr;
 
 static struct branch *current_branch;
 static const char *default_remote_name;
+static const char *pushremote_name;
 static int explicit_default_remote_name;
 
 static struct rewrites rewrites;
@@ -357,13 +358,16 @@ static int handle_config(const char *key, const char *value, void *cb)
                        return 0;
                branch = make_branch(name, subkey - name);
                if (!strcmp(subkey, ".remote")) {
-                       if (!value)
-                               return config_error_nonbool(key);
-                       branch->remote_name = xstrdup(value);
+                       if (git_config_string(&branch->remote_name, key, value))
+                               return -1;
                        if (branch == current_branch) {
                                default_remote_name = branch->remote_name;
                                explicit_default_remote_name = 1;
                        }
+               } else if (!strcmp(subkey, ".pushremote")) {
+                       if (branch == current_branch)
+                               if (git_config_string(&pushremote_name, key, value))
+                                       return -1;
                } else if (!strcmp(subkey, ".merge")) {
                        if (!value)
                                return config_error_nonbool(key);
@@ -389,9 +393,16 @@ static int handle_config(const char *key, const char *value, void *cb)
                        add_instead_of(rewrite, xstrdup(value));
                }
        }
+
        if (prefixcmp(key,  "remote."))
                return 0;
        name = key + 7;
+
+       /* Handle remote.* variables */
+       if (!strcmp(name, "pushdefault"))
+               return git_config_string(&pushremote_name, key, value);
+
+       /* Handle remote.<name>.* variables */
        if (*name == '/') {
                warning("Config remote shorthand cannot begin with '/': %s",
                        name);
@@ -671,17 +682,21 @@ static int valid_remote_nick(const char *name)
        return !strchr(name, '/'); /* no slash */
 }
 
-struct remote *remote_get(const char *name)
+static struct remote *remote_get_1(const char *name, const char *pushremote_name)
 {
        struct remote *ret;
        int name_given = 0;
 
-       read_config();
        if (name)
                name_given = 1;
        else {
-               name = default_remote_name;
-               name_given = explicit_default_remote_name;
+               if (pushremote_name) {
+                       name = pushremote_name;
+                       name_given = 1;
+               } else {
+                       name = default_remote_name;
+                       name_given = explicit_default_remote_name;
+               }
        }
 
        ret = make_remote(name, 0);
@@ -700,6 +715,18 @@ struct remote *remote_get(const char *name)
        return ret;
 }
 
+struct remote *remote_get(const char *name)
+{
+       read_config();
+       return remote_get_1(name, NULL);
+}
+
+struct remote *pushremote_get(const char *name)
+{
+       read_config();
+       return remote_get_1(name, pushremote_name);
+}
+
 int remote_is_configured(const char *name)
 {
        int i;
index 8743d6ef9df69167c08f3ea9b79b91fbd6ab09d3..cf5672466151254b92582ba4729a2a95e670beff 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -51,6 +51,7 @@ struct remote {
 };
 
 struct remote *remote_get(const char *name);
+struct remote *pushremote_get(const char *name);
 int remote_is_configured(const char *name);
 
 typedef int each_remote_fn(struct remote *remote, void *priv);
index 32ad89107b20fc2187b416bc7e3f4d45e17474c6..838e71dafea8388cbe18c82b26f58f074f56abbd 100755 (executable)
@@ -1,16 +1,28 @@
 #!/bin/sh
 
-test_description='fetching and pushing, with or without wildcard'
+test_description='Basic fetch/push functionality.
+
+This test checks the following functionality:
+
+* command-line syntax
+* refspecs
+* fast-forward detection, and overriding it
+* configuration
+* hooks
+* --porcelain output format
+* hiderefs
+'
 
 . ./test-lib.sh
 
 D=`pwd`
 
 mk_empty () {
-       rm -fr testrepo &&
-       mkdir testrepo &&
+       repo_name="$1"
+       rm -fr "$repo_name" &&
+       mkdir "$repo_name" &&
        (
-               cd testrepo &&
+               cd "$repo_name" &&
                git init &&
                git config receive.denyCurrentBranch warn &&
                mv .git/hooks .git/hooks-disabled
@@ -18,14 +30,17 @@ mk_empty () {
 }
 
 mk_test () {
-       mk_empty &&
+       repo_name="$1"
+       shift
+
+       mk_empty "$repo_name" &&
        (
                for ref in "$@"
                do
-                       git push testrepo $the_first_commit:refs/$ref ||
+                       git push "$repo_name" $the_first_commit:refs/$ref ||
                        exit
                done &&
-               cd testrepo &&
+               cd "$repo_name" &&
                for ref in "$@"
                do
                        echo "$the_first_commit" >expect &&
@@ -38,9 +53,10 @@ mk_test () {
 }
 
 mk_test_with_hooks() {
+       repo_name=$1
        mk_test "$@" &&
        (
-               cd testrepo &&
+               cd "$repo_name" &&
                mkdir .git/hooks &&
                cd .git/hooks &&
 
@@ -72,13 +88,16 @@ mk_test_with_hooks() {
 }
 
 mk_child() {
-       rm -rf "$1" &&
-       git clone testrepo "$1"
+       rm -rf "$2" &&
+       git clone "$1" "$2"
 }
 
 check_push_result () {
+       repo_name="$1"
+       shift
+
        (
-               cd testrepo &&
+               cd "$repo_name" &&
                echo "$1" >expect &&
                shift &&
                for ref in "$@"
@@ -108,7 +127,7 @@ test_expect_success setup '
 '
 
 test_expect_success 'fetch without wildcard' '
-       mk_empty &&
+       mk_empty testrepo &&
        (
                cd testrepo &&
                git fetch .. refs/heads/master:refs/remotes/origin/master &&
@@ -120,7 +139,7 @@ test_expect_success 'fetch without wildcard' '
 '
 
 test_expect_success 'fetch with wildcard' '
-       mk_empty &&
+       mk_empty testrepo &&
        (
                cd testrepo &&
                git config remote.up.url .. &&
@@ -134,7 +153,7 @@ test_expect_success 'fetch with wildcard' '
 '
 
 test_expect_success 'fetch with insteadOf' '
-       mk_empty &&
+       mk_empty testrepo &&
        (
                TRASH=$(pwd)/ &&
                cd testrepo &&
@@ -150,7 +169,7 @@ test_expect_success 'fetch with insteadOf' '
 '
 
 test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
-       mk_empty &&
+       mk_empty testrepo &&
        (
                TRASH=$(pwd)/ &&
                cd testrepo &&
@@ -166,7 +185,7 @@ test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
 '
 
 test_expect_success 'push without wildcard' '
-       mk_empty &&
+       mk_empty testrepo &&
 
        git push testrepo refs/heads/master:refs/remotes/origin/master &&
        (
@@ -178,7 +197,7 @@ test_expect_success 'push without wildcard' '
 '
 
 test_expect_success 'push with wildcard' '
-       mk_empty &&
+       mk_empty testrepo &&
 
        git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
        (
@@ -190,7 +209,7 @@ test_expect_success 'push with wildcard' '
 '
 
 test_expect_success 'push with insteadOf' '
-       mk_empty &&
+       mk_empty testrepo &&
        TRASH="$(pwd)/" &&
        test_config "url.$TRASH.insteadOf" trash/ &&
        git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
@@ -203,7 +222,7 @@ test_expect_success 'push with insteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf' '
-       mk_empty &&
+       mk_empty testrepo &&
        TRASH="$(pwd)/" &&
        test_config "url.$TRASH.pushInsteadOf" trash/ &&
        git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
@@ -216,7 +235,7 @@ test_expect_success 'push with pushInsteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf should not rewrite)' '
-       mk_empty &&
+       mk_empty testrepo &&
        test_config "url.trash2/.pushInsteadOf" testrepo/ &&
        test_config "url.trash3/.pusnInsteadOf" trash/wrong &&
        test_config remote.r.url trash/wrong &&
@@ -232,237 +251,237 @@ test_expect_success 'push with pushInsteadOf and explicit pushurl (pushInsteadOf
 
 test_expect_success 'push with matching heads' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo &&
-       check_push_result $the_commit heads/master
+       check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with matching heads on the command line' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo : &&
-       check_push_result $the_commit heads/master
+       check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'failed (non-fast-forward) push with matching heads' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo : &&
        git commit --amend -massaged &&
        test_must_fail git push testrepo &&
-       check_push_result $the_commit heads/master &&
+       check_push_result testrepo $the_commit heads/master &&
        git reset --hard $the_commit
 
 '
 
 test_expect_success 'push --force with matching heads' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo : &&
        git commit --amend -massaged &&
        git push --force testrepo &&
-       ! check_push_result $the_commit heads/master &&
+       ! check_push_result testrepo $the_commit heads/master &&
        git reset --hard $the_commit
 
 '
 
 test_expect_success 'push with matching heads and forced update' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo : &&
        git commit --amend -massaged &&
        git push testrepo +: &&
-       ! check_push_result $the_commit heads/master &&
+       ! check_push_result testrepo $the_commit heads/master &&
        git reset --hard $the_commit
 
 '
 
 test_expect_success 'push with no ambiguity (1)' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git push testrepo master:master &&
-       check_push_result $the_commit heads/master
+       check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with no ambiguity (2)' '
 
-       mk_test remotes/origin/master &&
+       mk_test testrepo remotes/origin/master &&
        git push testrepo master:origin/master &&
-       check_push_result $the_commit remotes/origin/master
+       check_push_result testrepo $the_commit remotes/origin/master
 
 '
 
 test_expect_success 'push with colon-less refspec, no ambiguity' '
 
-       mk_test heads/master heads/t/master &&
+       mk_test testrepo heads/master heads/t/master &&
        git branch -f t/master master &&
        git push testrepo master &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_first_commit heads/t/master
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_first_commit heads/t/master
 
 '
 
 test_expect_success 'push with weak ambiguity (1)' '
 
-       mk_test heads/master remotes/origin/master &&
+       mk_test testrepo heads/master remotes/origin/master &&
        git push testrepo master:master &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_first_commit remotes/origin/master
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_first_commit remotes/origin/master
 
 '
 
 test_expect_success 'push with weak ambiguity (2)' '
 
-       mk_test heads/master remotes/origin/master remotes/another/master &&
+       mk_test testrepo heads/master remotes/origin/master remotes/another/master &&
        git push testrepo master:master &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_first_commit remotes/origin/master remotes/another/master
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_first_commit remotes/origin/master remotes/another/master
 
 '
 
 test_expect_success 'push with ambiguity' '
 
-       mk_test heads/frotz tags/frotz &&
+       mk_test testrepo heads/frotz tags/frotz &&
        test_must_fail git push testrepo master:frotz &&
-       check_push_result $the_first_commit heads/frotz tags/frotz
+       check_push_result testrepo $the_first_commit heads/frotz tags/frotz
 
 '
 
 test_expect_success 'push with colon-less refspec (1)' '
 
-       mk_test heads/frotz tags/frotz &&
+       mk_test testrepo heads/frotz tags/frotz &&
        git branch -f frotz master &&
        git push testrepo frotz &&
-       check_push_result $the_commit heads/frotz &&
-       check_push_result $the_first_commit tags/frotz
+       check_push_result testrepo $the_commit heads/frotz &&
+       check_push_result testrepo $the_first_commit tags/frotz
 
 '
 
 test_expect_success 'push with colon-less refspec (2)' '
 
-       mk_test heads/frotz tags/frotz &&
+       mk_test testrepo heads/frotz tags/frotz &&
        if git show-ref --verify -q refs/heads/frotz
        then
                git branch -D frotz
        fi &&
        git tag -f frotz &&
        git push -f testrepo frotz &&
-       check_push_result $the_commit tags/frotz &&
-       check_push_result $the_first_commit heads/frotz
+       check_push_result testrepo $the_commit tags/frotz &&
+       check_push_result testrepo $the_first_commit heads/frotz
 
 '
 
 test_expect_success 'push with colon-less refspec (3)' '
 
-       mk_test &&
+       mk_test testrepo &&
        if git show-ref --verify -q refs/tags/frotz
        then
                git tag -d frotz
        fi &&
        git branch -f frotz master &&
        git push testrepo frotz &&
-       check_push_result $the_commit heads/frotz &&
+       check_push_result testrepo $the_commit heads/frotz &&
        test 1 = $( cd testrepo && git show-ref | wc -l )
 '
 
 test_expect_success 'push with colon-less refspec (4)' '
 
-       mk_test &&
+       mk_test testrepo &&
        if git show-ref --verify -q refs/heads/frotz
        then
                git branch -D frotz
        fi &&
        git tag -f frotz &&
        git push testrepo frotz &&
-       check_push_result $the_commit tags/frotz &&
+       check_push_result testrepo $the_commit tags/frotz &&
        test 1 = $( cd testrepo && git show-ref | wc -l )
 
 '
 
 test_expect_success 'push head with non-existent, incomplete dest' '
 
-       mk_test &&
+       mk_test testrepo &&
        git push testrepo master:branch &&
-       check_push_result $the_commit heads/branch
+       check_push_result testrepo $the_commit heads/branch
 
 '
 
 test_expect_success 'push tag with non-existent, incomplete dest' '
 
-       mk_test &&
+       mk_test testrepo &&
        git tag -f v1.0 &&
        git push testrepo v1.0:tag &&
-       check_push_result $the_commit tags/tag
+       check_push_result testrepo $the_commit tags/tag
 
 '
 
 test_expect_success 'push sha1 with non-existent, incomplete dest' '
 
-       mk_test &&
+       mk_test testrepo &&
        test_must_fail git push testrepo `git rev-parse master`:foo
 
 '
 
 test_expect_success 'push ref expression with non-existent, incomplete dest' '
 
-       mk_test &&
+       mk_test testrepo &&
        test_must_fail git push testrepo master^:branch
 
 '
 
 test_expect_success 'push with HEAD' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git checkout master &&
        git push testrepo HEAD &&
-       check_push_result $the_commit heads/master
+       check_push_result testrepo $the_commit heads/master
 
 '
 
 test_expect_success 'push with HEAD nonexisting at remote' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git checkout -b local master &&
        git push testrepo HEAD &&
-       check_push_result $the_commit heads/local
+       check_push_result testrepo $the_commit heads/local
 '
 
 test_expect_success 'push with +HEAD' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git checkout master &&
        git branch -D local &&
        git checkout -b local &&
        git push testrepo master local &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_commit heads/local &&
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_commit heads/local &&
 
        # Without force rewinding should fail
        git reset --hard HEAD^ &&
        test_must_fail git push testrepo HEAD &&
-       check_push_result $the_commit heads/local &&
+       check_push_result testrepo $the_commit heads/local &&
 
        # With force rewinding should succeed
        git push testrepo +HEAD &&
-       check_push_result $the_first_commit heads/local
+       check_push_result testrepo $the_first_commit heads/local
 
 '
 
 test_expect_success 'push HEAD with non-existent, incomplete dest' '
 
-       mk_test &&
+       mk_test testrepo &&
        git checkout master &&
        git push testrepo HEAD:branch &&
-       check_push_result $the_commit heads/branch
+       check_push_result testrepo $the_commit heads/branch
 
 '
 
 test_expect_success 'push with config remote.*.push = HEAD' '
 
-       mk_test heads/local &&
+       mk_test testrepo heads/local &&
        git checkout master &&
        git branch -f local $the_commit &&
        (
@@ -474,35 +493,62 @@ test_expect_success 'push with config remote.*.push = HEAD' '
        test_config remote.there.push HEAD &&
        test_config branch.master.remote there &&
        git push &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_first_commit heads/local
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_first_commit heads/local
+'
+
+test_expect_success 'push with remote.pushdefault' '
+       mk_test up_repo heads/master &&
+       mk_test down_repo heads/master &&
+       test_config remote.up.url up_repo &&
+       test_config remote.down.url down_repo &&
+       test_config branch.master.remote up &&
+       test_config remote.pushdefault down &&
+       git push &&
+       check_push_result up_repo $the_first_commit heads/master &&
+       check_push_result down_repo $the_commit heads/master
 '
 
 test_expect_success 'push with config remote.*.pushurl' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git checkout master &&
        test_config remote.there.url test2repo &&
        test_config remote.there.pushurl testrepo &&
        git push there &&
-       check_push_result $the_commit heads/master
+       check_push_result testrepo $the_commit heads/master
+'
+
+test_expect_success 'push with config branch.*.pushremote' '
+       mk_test up_repo heads/master &&
+       mk_test side_repo heads/master &&
+       mk_test down_repo heads/master &&
+       test_config remote.up.url up_repo &&
+       test_config remote.pushdefault side_repo &&
+       test_config remote.down.url down_repo &&
+       test_config branch.master.remote up &&
+       test_config branch.master.pushremote down &&
+       git push &&
+       check_push_result up_repo $the_first_commit heads/master &&
+       check_push_result side_repo $the_first_commit heads/master &&
+       check_push_result down_repo $the_commit heads/master
 '
 
 test_expect_success 'push with dry-run' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (
                cd testrepo &&
                old_commit=$(git show-ref -s --verify refs/heads/master)
        ) &&
        git push --dry-run testrepo &&
-       check_push_result $old_commit heads/master
+       check_push_result testrepo $old_commit heads/master
 '
 
 test_expect_success 'push updates local refs' '
 
-       mk_test heads/master &&
-       mk_child child &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child &&
        (
                cd child &&
                git pull .. master &&
@@ -515,9 +561,9 @@ test_expect_success 'push updates local refs' '
 
 test_expect_success 'push updates up-to-date local refs' '
 
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child1 &&
+       mk_child testrepo child2 &&
        (cd child1 && git pull .. master && git push) &&
        (
                cd child2 &&
@@ -531,8 +577,8 @@ test_expect_success 'push updates up-to-date local refs' '
 
 test_expect_success 'push preserves up-to-date packed refs' '
 
-       mk_test heads/master &&
-       mk_child child &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child &&
        (
                cd child &&
                git push &&
@@ -543,8 +589,8 @@ test_expect_success 'push preserves up-to-date packed refs' '
 
 test_expect_success 'push does not update local refs on failure' '
 
-       mk_test heads/master &&
-       mk_child child &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child &&
        mkdir testrepo/.git/hooks &&
        echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
        chmod +x testrepo/.git/hooks/pre-receive &&
@@ -560,7 +606,7 @@ test_expect_success 'push does not update local refs on failure' '
 
 test_expect_success 'allow deleting an invalid remote ref' '
 
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        rm -f testrepo/.git/objects/??/* &&
        git push testrepo :refs/heads/master &&
        (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
@@ -568,7 +614,7 @@ test_expect_success 'allow deleting an invalid remote ref' '
 '
 
 test_expect_success 'pushing valid refs triggers post-receive and post-update hooks' '
-       mk_test_with_hooks heads/master heads/next &&
+       mk_test_with_hooks testrepo heads/master heads/next &&
        orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
        newmaster=$(git show-ref -s --verify refs/heads/master) &&
        orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
@@ -604,7 +650,7 @@ test_expect_success 'pushing valid refs triggers post-receive and post-update ho
 '
 
 test_expect_success 'deleting dangling ref triggers hooks with correct args' '
-       mk_test_with_hooks heads/master &&
+       mk_test_with_hooks testrepo heads/master &&
        rm -f testrepo/.git/objects/??/* &&
        git push testrepo :refs/heads/master &&
        (
@@ -633,7 +679,7 @@ test_expect_success 'deleting dangling ref triggers hooks with correct args' '
 '
 
 test_expect_success 'deletion of a non-existent ref is not fed to post-receive and post-update hooks' '
-       mk_test_with_hooks heads/master &&
+       mk_test_with_hooks testrepo heads/master &&
        orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
        newmaster=$(git show-ref -s --verify refs/heads/master) &&
        git push testrepo master :refs/heads/nonexistent &&
@@ -665,7 +711,7 @@ test_expect_success 'deletion of a non-existent ref is not fed to post-receive a
 '
 
 test_expect_success 'deletion of a non-existent ref alone does trigger post-receive and post-update hooks' '
-       mk_test_with_hooks heads/master &&
+       mk_test_with_hooks testrepo heads/master &&
        git push testrepo :refs/heads/nonexistent &&
        (
                cd testrepo/.git &&
@@ -685,7 +731,7 @@ test_expect_success 'deletion of a non-existent ref alone does trigger post-rece
 '
 
 test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks with correct input' '
-       mk_test_with_hooks heads/master heads/next heads/pu &&
+       mk_test_with_hooks testrepo heads/master heads/next heads/pu &&
        orgmaster=$(cd testrepo && git show-ref -s --verify refs/heads/master) &&
        newmaster=$(git show-ref -s --verify refs/heads/master) &&
        orgnext=$(cd testrepo && git show-ref -s --verify refs/heads/next) &&
@@ -731,14 +777,14 @@ test_expect_success 'mixed ref updates, deletes, invalid deletes trigger hooks w
 '
 
 test_expect_success 'allow deleting a ref using --delete' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (cd testrepo && git config receive.denyDeleteCurrent warn) &&
        git push testrepo --delete master &&
        (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
 '
 
 test_expect_success 'allow deleting a tag using --delete' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        git tag -a -m dummy_message deltag heads/master &&
        git push testrepo --tags &&
        (cd testrepo && git rev-parse --verify -q refs/tags/deltag) &&
@@ -747,17 +793,17 @@ test_expect_success 'allow deleting a tag using --delete' '
 '
 
 test_expect_success 'push --delete without args aborts' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        test_must_fail git push testrepo --delete
 '
 
 test_expect_success 'push --delete refuses src:dest refspecs' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        test_must_fail git push testrepo --delete master:foo
 '
 
 test_expect_success 'warn on push to HEAD of non-bare repository' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (
                cd testrepo &&
                git checkout master &&
@@ -768,7 +814,7 @@ test_expect_success 'warn on push to HEAD of non-bare repository' '
 '
 
 test_expect_success 'deny push to HEAD of non-bare repository' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (
                cd testrepo &&
                git checkout master &&
@@ -778,7 +824,7 @@ test_expect_success 'deny push to HEAD of non-bare repository' '
 '
 
 test_expect_success 'allow push to HEAD of bare repository (bare)' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (
                cd testrepo &&
                git checkout master &&
@@ -790,7 +836,7 @@ test_expect_success 'allow push to HEAD of bare repository (bare)' '
 '
 
 test_expect_success 'allow push to HEAD of non-bare repository (config)' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        (
                cd testrepo &&
                git checkout master &&
@@ -801,7 +847,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
 '
 
 test_expect_success 'fetch with branches' '
-       mk_empty &&
+       mk_empty testrepo &&
        git branch second $the_first_commit &&
        git checkout second &&
        echo ".." > testrepo/.git/branches/branch1 &&
@@ -816,7 +862,7 @@ test_expect_success 'fetch with branches' '
 '
 
 test_expect_success 'fetch with branches containing #' '
-       mk_empty &&
+       mk_empty testrepo &&
        echo "..#second" > testrepo/.git/branches/branch2 &&
        (
                cd testrepo &&
@@ -829,7 +875,7 @@ test_expect_success 'fetch with branches containing #' '
 '
 
 test_expect_success 'push with branches' '
-       mk_empty &&
+       mk_empty testrepo &&
        git checkout second &&
        echo "testrepo" > .git/branches/branch1 &&
        git push branch1 &&
@@ -842,7 +888,7 @@ test_expect_success 'push with branches' '
 '
 
 test_expect_success 'push with branches containing #' '
-       mk_empty &&
+       mk_empty testrepo &&
        echo "testrepo#branch3" > .git/branches/branch2 &&
        git push branch2 &&
        (
@@ -855,9 +901,9 @@ test_expect_success 'push with branches containing #' '
 '
 
 test_expect_success 'push into aliased refs (consistent)' '
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child1 &&
+       mk_child testrepo child2 &&
        (
                cd child1 &&
                git branch foo &&
@@ -877,9 +923,9 @@ test_expect_success 'push into aliased refs (consistent)' '
 '
 
 test_expect_success 'push into aliased refs (inconsistent)' '
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child1 &&
+       mk_child testrepo child2 &&
        (
                cd child1 &&
                git branch foo &&
@@ -904,9 +950,9 @@ test_expect_success 'push into aliased refs (inconsistent)' '
 '
 
 test_expect_success 'push requires --force to update lightweight tag' '
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
+       mk_test testrepo heads/master &&
+       mk_child testrepo child1 &&
+       mk_child testrepo child2 &&
        (
                cd child1 &&
                git tag Tag &&
@@ -925,7 +971,7 @@ test_expect_success 'push requires --force to update lightweight tag' '
 '
 
 test_expect_success 'push --porcelain' '
-       mk_empty &&
+       mk_empty testrepo &&
        echo >.git/foo  "To testrepo" &&
        echo >>.git/foo "*      refs/heads/master:refs/remotes/origin/master    [new branch]"  &&
        echo >>.git/foo "Done" &&
@@ -940,13 +986,13 @@ test_expect_success 'push --porcelain' '
 '
 
 test_expect_success 'push --porcelain bad url' '
-       mk_empty &&
+       mk_empty testrepo &&
        test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
        test_must_fail grep -q Done .git/bar
 '
 
 test_expect_success 'push --porcelain rejected' '
-       mk_empty &&
+       mk_empty testrepo &&
        git push testrepo refs/heads/master:refs/remotes/origin/master &&
        (cd testrepo &&
                git reset --hard origin/master^
@@ -960,7 +1006,7 @@ test_expect_success 'push --porcelain rejected' '
 '
 
 test_expect_success 'push --porcelain --dry-run rejected' '
-       mk_empty &&
+       mk_empty testrepo &&
        git push testrepo refs/heads/master:refs/remotes/origin/master &&
        (cd testrepo &&
                git reset --hard origin/master
@@ -975,25 +1021,25 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 '
 
 test_expect_success 'push --prune' '
-       mk_test heads/master heads/second heads/foo heads/bar &&
+       mk_test testrepo heads/master heads/second heads/foo heads/bar &&
        git push --prune testrepo &&
-       check_push_result $the_commit heads/master &&
-       check_push_result $the_first_commit heads/second &&
-       ! check_push_result $the_first_commit heads/foo heads/bar
+       check_push_result testrepo $the_commit heads/master &&
+       check_push_result testrepo $the_first_commit heads/second &&
+       ! check_push_result testrepo $the_first_commit heads/foo heads/bar
 '
 
 test_expect_success 'push --prune refspec' '
-       mk_test tmp/master tmp/second tmp/foo tmp/bar &&
+       mk_test testrepo tmp/master tmp/second tmp/foo tmp/bar &&
        git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
-       check_push_result $the_commit tmp/master &&
-       check_push_result $the_first_commit tmp/second &&
-       ! check_push_result $the_first_commit tmp/foo tmp/bar
+       check_push_result testrepo $the_commit tmp/master &&
+       check_push_result testrepo $the_first_commit tmp/second &&
+       ! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
 '
 
 for configsection in transfer receive
 do
        test_expect_success "push to update a ref hidden by $configsection.hiderefs" '
-               mk_test heads/master hidden/one hidden/two hidden/three &&
+               mk_test testrepo heads/master hidden/one hidden/two hidden/three &&
                (
                        cd testrepo &&
                        git config $configsection.hiderefs refs/hidden
@@ -1001,32 +1047,32 @@ do
 
                # push to unhidden ref succeeds normally
                git push testrepo master:refs/heads/master &&
-               check_push_result $the_commit heads/master &&
+               check_push_result testrepo $the_commit heads/master &&
 
                # push to update a hidden ref should fail
                test_must_fail git push testrepo master:refs/hidden/one &&
-               check_push_result $the_first_commit hidden/one &&
+               check_push_result testrepo $the_first_commit hidden/one &&
 
                # push to delete a hidden ref should fail
                test_must_fail git push testrepo :refs/hidden/two &&
-               check_push_result $the_first_commit hidden/two &&
+               check_push_result testrepo $the_first_commit hidden/two &&
 
                # idempotent push to update a hidden ref should fail
                test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
-               check_push_result $the_first_commit hidden/three
+               check_push_result testrepo $the_first_commit hidden/three
        '
 done
 
 test_expect_success 'fetch exact SHA1' '
-       mk_test heads/master hidden/one &&
+       mk_test testrepo heads/master hidden/one &&
        git push testrepo master:refs/hidden/one &&
        (
                cd testrepo &&
                git config transfer.hiderefs refs/hidden
        ) &&
-       check_push_result $the_commit hidden/one &&
+       check_push_result testrepo $the_commit hidden/one &&
 
-       mk_child child &&
+       mk_child testrepo child &&
        (
                cd child &&
 
@@ -1052,7 +1098,7 @@ test_expect_success 'fetch exact SHA1' '
 '
 
 test_expect_success 'fetch follows tags by default' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        rm -fr src dst &&
        git init src &&
        (
@@ -1079,7 +1125,7 @@ test_expect_success 'fetch follows tags by default' '
 '
 
 test_expect_success 'push does not follow tags by default' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        rm -fr src dst &&
        git init src &&
        git init --bare dst &&
@@ -1102,7 +1148,7 @@ test_expect_success 'push does not follow tags by default' '
 '
 
 test_expect_success 'push --follow-tag only pushes relevant tags' '
-       mk_test heads/master &&
+       mk_test testrepo heads/master &&
        rm -fr src dst &&
        git init src &&
        git init --bare dst &&