summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be6042c)
raw | patch | inline | side by side (parent: be6042c)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 15 Sep 2007 07:23:14 +0000 (03:23 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 19 Sep 2007 10:22:31 +0000 (03:22 -0700) |
We don't actually need to know at the time of transport_get if the
caller wants to fetch, push, or do both on the returned object.
It is easier to just delay the initialization of the HTTP walker
until we know we will need it by providing a CURL specific fetch
function in the curl_transport that makes sure the walker instance
is initialized before use.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
caller wants to fetch, push, or do both on the returned object.
It is easier to just delay the initialization of the HTTP walker
until we know we will need it by providing a CURL specific fetch
function in the curl_transport that makes sure the walker instance
is initialized before use.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch.c | patch | blob | history | |
builtin-push.c | patch | blob | history | |
transport.c | patch | blob | history | |
transport.h | patch | blob | history |
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 8b0fdbe90502e16117d0bf4ea2193e830fa7857f..300d5635b09ff123918a2c5797c121223b8d70cb 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
else
remote = remote_get(argv[i++]);
- transport = transport_get(remote, remote->uri[0], 1);
+ transport = transport_get(remote, remote->uri[0]);
if (verbose >= 2)
transport->verbose = 1;
if (quiet)
diff --git a/builtin-push.c b/builtin-push.c
index f496b460073827cc14ce2e224bc9756735b0141f..7d7e826a39707cbd81d346b7eef1e625bee4b417 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
errs = 0;
for (i = 0; i < remote->uri_nr; i++) {
struct transport *transport =
- transport_get(remote, remote->uri[i], 0);
+ transport_get(remote, remote->uri[i]);
int err;
if (receivepack)
transport_set_option(transport,
diff --git a/transport.c b/transport.c
index 5eabe8de0b6b3387fbfeff50177083a28f30078c..7f94d30f95c26b8139fe7d63059633303f719d66 100644 (file)
--- a/transport.c
+++ b/transport.c
return refs;
}
+static int fetch_objs_via_curl(struct transport *transport,
+ int nr_objs, struct ref **to_fetch)
+{
+ if (!transport->data)
+ transport->data = get_http_walker(transport->url);
+ return fetch_objs_via_walker(transport, nr_objs, to_fetch);
+}
+
#else
static struct ref *get_refs_via_curl(const struct transport *transport)
return NULL;
}
+static int fetch_objs_via_curl(struct transport *transport,
+ int nr_objs, struct ref **to_fetch)
+{
+ die("Cannot fetch from '%s' without curl ...", transport->url);
+ return -1;
+}
+
#endif
static const struct transport_ops curl_transport = {
/* set_option */ NULL,
/* get_refs_list */ get_refs_via_curl,
- /* fetch */ fetch_objs_via_walker,
+ /* fetch */ fetch_objs_via_curl,
/* push */ curl_transport_push,
/* disconnect */ disconnect_walker
};
return S_ISREG(buf.st_mode);
}
-struct transport *transport_get(struct remote *remote, const char *url,
- int fetch)
+struct transport *transport_get(struct remote *remote, const char *url)
{
struct transport *ret = xcalloc(1, sizeof(*ret));
ret->remote = remote;
ret->url = url;
- ret->fetch = !!fetch;
if (!prefixcmp(url, "rsync://")) {
ret->ops = &rsync_transport;
|| !prefixcmp(url, "https://")
|| !prefixcmp(url, "ftp://")) {
ret->ops = &curl_transport;
- if (fetch)
- ret->data = get_http_walker(url);
} else if (is_local(url) && is_file(url)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
ret->data = data;
diff --git a/transport.h b/transport.h
index f2bbdf778a80e6d8099dd4001bf9dfdf39e43e9d..6a95d6605342e2dd42b39bd38e87065e42541f74 100644 (file)
--- a/transport.h
+++ b/transport.h
struct transport {
unsigned verbose : 1;
- unsigned fetch : 1;
struct remote *remote;
const char *url;
};
/* Returns a transport suitable for the url */
-struct transport *transport_get(struct remote *remote, const char *url,
- int fetch);
+struct transport *transport_get(struct remote *, const char *);
/* Transport options which apply to git:// and scp-style URLs */