diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-09-15 03:23:14 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-19 03:22:31 -0700 |
commit | e5f4e214636f9c9bd36c2897634108d5ad5587a1 (patch) | |
tree | 297b615846c859e93f20c8aa9cf5262d13a849ff /transport.c | |
parent | be6042cfa59358b733b6f9ba05bcbc317998d9fe (diff) | |
download | git-e5f4e214636f9c9bd36c2897634108d5ad5587a1.tar.gz |
Remove unnecessary 'fetch' argument from transport_get API
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>
Diffstat (limited to 'transport.c')
-rw-r--r-- | transport.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/transport.c b/transport.c index 5eabe8de0b..7f94d30f95 100644 --- a/transport.c +++ b/transport.c @@ -174,6 +174,14 @@ static struct ref *get_refs_via_curl(const struct transport *transport) 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) @@ -182,12 +190,19 @@ 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 }; @@ -408,14 +423,12 @@ static int is_file(const char *url) 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; @@ -423,8 +436,6 @@ struct transport *transport_get(struct remote *remote, const char *url, || !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; |