From: Johan Herland <johan@herland.net>
To: git@vger.kernel.org
Cc: Johan Herland <johan@herland.net>,
barkalow@iabervon.org, gitster@pobox.com,
benji@silverinsanity.com, Johannes.Schindelin@gmx.de
Subject: [RFC/PATCH 3/6] Move setup of curl remote helper from transport.c to transport-helper.c
Date: Tue, 11 Aug 2009 12:10:23 +0200 [thread overview]
Message-ID: <1249985426-13726-4-git-send-email-johan@herland.net> (raw)
In-Reply-To: <alpine.LNX.2.00.0908101205120.27553@iabervon.org>
Since the curl transport is now launched by the transport-helper mechanism,
it makes sense to move the remaining curl-related code (i.e.
curl_transport_push()) from transport.c into transport-helper.c.
The patch also consolidates the two transport_helper_init() call sites
("foreign" helper and curl helper).
Signed-off-by: Johan Herland <johan@herland.net>
---
transport-helper.c | 39 +++++++++++++++++++++++++++++++++++++++
transport.c | 48 ++++++------------------------------------------
2 files changed, 45 insertions(+), 42 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index a901630..d3ce984 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -249,6 +249,34 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
return ret;
}
+#ifndef NO_CURL
+static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags)
+{
+ const char **argv;
+ int argc;
+
+ if (flags & TRANSPORT_PUSH_MIRROR)
+ return error("http transport does not support mirror mode");
+
+ argv = xmalloc((refspec_nr + 12) * sizeof(char *));
+ argv[0] = "http-push";
+ argc = 1;
+ if (flags & TRANSPORT_PUSH_ALL)
+ argv[argc++] = "--all";
+ if (flags & TRANSPORT_PUSH_FORCE)
+ argv[argc++] = "--force";
+ if (flags & TRANSPORT_PUSH_DRY_RUN)
+ argv[argc++] = "--dry-run";
+ if (flags & TRANSPORT_PUSH_VERBOSE)
+ argv[argc++] = "--verbose";
+ argv[argc++] = transport->url;
+ while (refspec_nr--)
+ argv[argc++] = *refspec++;
+ argv[argc] = NULL;
+ return !!run_command_v_opt(argv, RUN_GIT_CMD);
+}
+#endif
+
int transport_helper_init(struct transport *transport)
{
struct helper_data *data = xcalloc(sizeof(*data), 1);
@@ -269,5 +297,16 @@ int transport_helper_init(struct transport *transport)
transport->get_refs_list = get_refs_list;
transport->fetch = fetch;
transport->disconnect = disconnect_helper;
+
+ if (!strcmp(data->name, "http")
+ || !strcmp(data->name, "https")
+ || !strcmp(data->name, "ftp")) {
+#ifdef NO_CURL
+ error("git was compiled without libcurl support.");
+#else
+ transport->push = curl_transport_push;
+#endif
+ }
+
return 0;
}
diff --git a/transport.c b/transport.c
index 26d9999..81a28bc 100644
--- a/transport.c
+++ b/transport.c
@@ -349,35 +349,6 @@ static int rsync_transport_push(struct transport *transport,
return result;
}
-#ifndef NO_CURL
-static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags)
-{
- const char **argv;
- int argc;
-
- if (flags & TRANSPORT_PUSH_MIRROR)
- return error("http transport does not support mirror mode");
-
- argv = xmalloc((refspec_nr + 12) * sizeof(char *));
- argv[0] = "http-push";
- argc = 1;
- if (flags & TRANSPORT_PUSH_ALL)
- argv[argc++] = "--all";
- if (flags & TRANSPORT_PUSH_FORCE)
- argv[argc++] = "--force";
- if (flags & TRANSPORT_PUSH_DRY_RUN)
- argv[argc++] = "--dry-run";
- if (flags & TRANSPORT_PUSH_VERBOSE)
- argv[argc++] = "--verbose";
- argv[argc++] = transport->url;
- while (refspec_nr--)
- argv[argc++] = *refspec++;
- argv[argc] = NULL;
- return !!run_command_v_opt(argv, RUN_GIT_CMD);
-}
-
-#endif
-
struct bundle_transport_data {
int fd;
struct bundle_header header;
@@ -815,26 +786,19 @@ struct transport *transport_get(struct remote *remote, const char *url)
url = remote->url[0];
ret->url = url;
- if (remote && remote->foreign_vcs) {
- transport_helper_init(ret);
- return ret;
- }
+ if (remote && remote->foreign_vcs)
+ url = NULL;
if (url && !prefixcmp(url, "rsync:")) {
ret->get_refs_list = get_refs_via_rsync;
ret->fetch = fetch_objs_via_rsync;
ret->push = rsync_transport_push;
- } else if (url
- && (!prefixcmp(url, "http://")
- || !prefixcmp(url, "https://")
- || !prefixcmp(url, "ftp://"))) {
+ } else if (!url
+ || !prefixcmp(url, "http://")
+ || !prefixcmp(url, "https://")
+ || !prefixcmp(url, "ftp://")) {
transport_helper_init(ret);
-#ifdef NO_CURL
- error("git was compiled without libcurl support.");
-#else
- ret->push = curl_transport_push;
-#endif
} else if (url && is_local(url) && is_file(url)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
--
1.6.4.rc3.138.ga6b98.dirty
next prev parent reply other threads:[~2009-08-11 13:12 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-09 19:28 [PATCH 5/8] Add a config option for remotes to specify a foreign vcs Daniel Barkalow
2009-08-09 20:38 ` Johannes Schindelin
2009-08-10 1:15 ` Junio C Hamano
2009-08-10 4:30 ` Daniel Barkalow
2009-08-10 8:32 ` Johan Herland
2009-08-10 19:30 ` Daniel Barkalow
2009-08-11 10:10 ` [RFC/PATCH 0/6] Graceful handling of missing remote helpers Johan Herland
2009-08-11 10:10 ` [RFC/PATCH 1/6] Minor unrelated fixes Johan Herland
2009-08-11 10:10 ` [RFC/PATCH 2/6] transport_get(): Don't SEGFAULT on missing url Johan Herland
2009-08-12 22:24 ` Junio C Hamano
2009-08-12 23:39 ` Johan Herland
2009-08-11 10:10 ` Johan Herland [this message]
2009-08-11 12:23 ` [RFC/PATCH 3/6] Move setup of curl remote helper from transport.c to transport-helper.c Johannes Schindelin
2009-08-11 10:10 ` [RFC/PATCH 4/6] Add is_git_command_or_alias() for checking availability of a given git command Johan Herland
2009-08-11 12:21 ` Johannes Schindelin
2009-08-11 10:10 ` [RFC/PATCH 5/6] Let transport_helper_init() decide if a remote helper program can be used Johan Herland
2009-08-11 12:21 ` Johannes Schindelin
2009-08-11 23:28 ` Daniel Barkalow
2009-08-12 7:46 ` Jeff King
2009-08-12 16:21 ` Daniel Barkalow
2009-08-11 10:10 ` [RFC/PATCH 6/6] Add testcase to verify handling of missing remote helper programs Johan Herland
2009-08-11 5:12 ` [PATCH 5/8] Add a config option for remotes to specify a foreign vcs Junio C Hamano
2009-08-11 8:39 ` Johannes Schindelin
2009-08-10 8:47 ` Junio C Hamano
2009-08-11 15:31 ` Bert Wesarg
2009-08-11 16:20 ` Johannes Schindelin
2009-08-11 21:48 ` Jeff King
[not found] ` <20090812075914.6117@nanako3.lavabit.com>
2009-08-11 23:02 ` Jeff King
2009-08-12 0:14 ` Johannes Schindelin
2009-08-12 3:26 ` Junio C Hamano
2009-08-11 23:53 ` Johannes Schindelin
2009-08-12 7:45 ` Jeff King
2009-08-12 9:33 ` Jakub Narebski
2009-08-12 20:30 ` Junio C Hamano
2009-08-13 22:00 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249985426-13726-4-git-send-email-johan@herland.net \
--to=johan@herland.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=benji@silverinsanity.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).