aboutsummaryrefslogtreecommitdiff
path: root/builtin-push.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2009-06-09 18:01:34 +0200
committerJunio C Hamano <gitster@pobox.com>2009-06-09 23:46:47 -0700
commit203462347fce0eab563fe77640648a7e8ae64d3b (patch)
treed5cc723473be92132fd19e120b721f461a14c9ed /builtin-push.c
parentf4f78e668dd40f2d4a5bc119cccb3c34c2675c38 (diff)
downloadgit-203462347fce0eab563fe77640648a7e8ae64d3b.tar.gz
git-203462347fce0eab563fe77640648a7e8ae64d3b.tar.xz
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>
Diffstat (limited to 'builtin-push.c')
-rw-r--r--builtin-push.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/builtin-push.c b/builtin-push.c
index c86997401..7be12399b 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -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;