Allow push and fetch urls to be different

This introduces a config setting remote.$remotename.pushurl which is
used for pushes only. If absent remote.$remotename.url is used for
pushes and fetches as before.
This is useful, for example, in order to do passwordless fetches
(remote update) over the git transport but pushes over ssh.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael J Gruber
2009-06-09 18:01:34 +02:00
committed by Junio C Hamano
parent f4f78e668d
commit 203462347f
5 changed files with 37 additions and 4 deletions

View File

@ -117,6 +117,8 @@ static int do_push(const char *repo, int flags)
{
int i, errs;
struct remote *remote = remote_get(repo);
const char **url;
int url_nr;
if (!remote) {
if (repo)
@ -152,9 +154,16 @@ static int do_push(const char *repo, int flags)
setup_default_push_refspecs();
}
errs = 0;
for (i = 0; i < remote->url_nr; i++) {
if (remote->pushurl_nr) {
url = remote->pushurl;
url_nr = remote->pushurl_nr;
} else {
url = remote->url;
url_nr = remote->url_nr;
}
for (i = 0; i < url_nr; i++) {
struct transport *transport =
transport_get(remote, remote->url[i]);
transport_get(remote, url[i]);
int err;
if (receivepack)
transport_set_option(transport,
@ -163,14 +172,14 @@ static int do_push(const char *repo, int flags)
transport_set_option(transport, TRANS_OPT_THIN, "yes");
if (flags & TRANSPORT_PUSH_VERBOSE)
fprintf(stderr, "Pushing to %s\n", remote->url[i]);
fprintf(stderr, "Pushing to %s\n", url[i]);
err = transport_push(transport, refspec_nr, refspec, flags);
err |= transport_disconnect(transport);
if (!err)
continue;
error("failed to push some refs to '%s'", remote->url[i]);
error("failed to push some refs to '%s'", url[i]);
errs++;
}
return !!errs;