summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f4f78e6)
raw | patch | inline | side by side (parent: f4f78e6)
author | Michael J Gruber <git@drmicha.warpmail.net> | |
Tue, 9 Jun 2009 16:01:34 +0000 (18:01 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 10 Jun 2009 06:46:47 +0000 (23:46 -0700) |
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>
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>
index 3a86d1f8f05317717d718a6db7c5e0f9acb47d6b..2fecbe32a68bd981959735dd14e6e311d16b233a 100644 (file)
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
The URL of a remote repository. See linkgit:git-fetch[1] or
linkgit:git-push[1].
+remote.<name>.pushurl::
+ The push URL of a remote repository. See linkgit:git-push[1].
+
remote.<name>.proxy::
For remotes that require curl (http, https and ftp), the URL to
the proxy to use for that remote. Set to the empty string to
index 41ec7774f481fd2d70492be4ab2b5e0bf887fc0b..2a0e7b89441039699a3dc9514f1165cb2112020a 100644 (file)
------------
[remote "<name>"]
url = <url>
+ pushurl = <pushurl>
push = <refspec>
fetch = <refspec>
------------
+The `<pushurl>` is used for pushes only. It is optional and defaults
+to `<url>`.
Named file in `$GIT_DIR/remotes`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/builtin-push.c b/builtin-push.c
index c869974013b5c1bb563d4f9b306820362545c9ea..7be12399b6d95c63efd9102df7967dca61655063 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
{
int i, errs;
struct remote *remote = remote_get(repo);
+ const char **url;
+ int url_nr;
if (!remote) {
if (repo)
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,
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;
diff --git a/remote.c b/remote.c
index 2c3e9053a492e0029eb1f98a8d2c649564888197..4544d65c72c825a1e3e71f9e1a1052f0574f2a9a 100644 (file)
--- a/remote.c
+++ b/remote.c
add_url(remote, alias_url(url));
}
+static void add_pushurl(struct remote *remote, const char *pushurl)
+{
+ ALLOC_GROW(remote->pushurl, remote->pushurl_nr + 1, remote->pushurl_alloc);
+ remote->pushurl[remote->pushurl_nr++] = pushurl;
+}
+
static struct remote *make_remote(const char *name, int len)
{
struct remote *ret;
if (git_config_string(&v, key, value))
return -1;
add_url(remote, v);
+ } else if (!strcmp(subkey, ".pushurl")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_pushurl(remote, v);
} else if (!strcmp(subkey, ".push")) {
const char *v;
if (git_config_string(&v, key, value))
for (j = 0; j < remotes[i]->url_nr; j++) {
remotes[i]->url[j] = alias_url(remotes[i]->url[j]);
}
+ for (j = 0; j < remotes[i]->pushurl_nr; j++) {
+ remotes[i]->pushurl[j] = alias_url(remotes[i]->pushurl[j]);
+ }
}
}
diff --git a/remote.h b/remote.h
index 99706a89bc6011c01fcd661d8bad4b26f59b0ca7..326bffeb0c4dbf4e675e714ce74d77e0cf78fe70 100644 (file)
--- a/remote.h
+++ b/remote.h
int url_nr;
int url_alloc;
+ const char **pushurl;
+ int pushurl_nr;
+ int pushurl_alloc;
+
const char **push_refspec;
struct refspec *push;
int push_refspec_nr;