From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, Daniel Barkalow <barkalow@iabervon.org>
Subject: [PATCH 2/3] Add bundle transport
Date: Tue, 17 Jul 2007 23:49:53 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0707172349360.14781@racer.site> (raw)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
transport.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/transport.c b/transport.c
index f444c5b..1532276 100644
--- a/transport.c
+++ b/transport.c
@@ -5,6 +5,7 @@
#include "pkt-line.h"
#include "fetch-pack.h"
#include "walker.h"
+#include "bundle.h"
/* Generic functions for using commit walkers */
@@ -185,7 +186,55 @@ static const struct transport_ops curl_transport = {
/* disconnect */ disconnect_walker
};
+struct bundle_transport_data {
+ int fd;
+ struct bundle_header header;
+};
+
+static struct ref *get_refs_from_bundle(const struct transport *transport)
+{
+ struct bundle_transport_data *data = transport->data;
+ struct ref *result = NULL;
+ int i;
+
+ if (data->fd > 0)
+ close(data->fd);
+ data->fd = read_bundle_header(transport->url, &data->header);
+ if (data->fd < 0)
+ die ("Could not read bundle '%s'.", transport->url);
+ for (i = 0; i < data->header.references.nr; i++) {
+ struct ref_list_entry *e = data->header.references.list + i;
+ struct ref *ref = alloc_ref(strlen(e->name));
+ hashcpy(ref->old_sha1, e->sha1);
+ strcpy(ref->name, e->name);
+ ref->next = result;
+ result = ref;
+ }
+ return result;
+}
+
+static int fetch_refs_from_bundle(const struct transport *transport,
+ int nr_heads, char **heads)
+{
+ struct bundle_transport_data *data = transport->data;
+ return unbundle(&data->header, data->fd);
+}
+
+static int close_bundle(struct transport *transport)
+{
+ struct bundle_transport_data *data = transport->data;
+ if (data->fd > 0)
+ close(data->fd);
+ return 0;
+}
+
static const struct transport_ops bundle_transport = {
+ /* set_option */ NULL,
+ /* get_refs_list */ get_refs_from_bundle,
+ /* fetch_refs */ fetch_refs_from_bundle,
+ /* fetch_objs */ NULL,
+ /* push */ NULL,
+ /* disconnect */ close_bundle
};
struct git_transport_data {
@@ -359,8 +408,9 @@ struct transport *transport_get(struct remote *remote, const char *url,
else
ret->data = NULL;
} else if (is_local(url) && is_file(url)) {
+ struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
ret = xmalloc(sizeof(*ret));
- ret->data = NULL;
+ ret->data = data;
ret->ops = &bundle_transport;
} else {
struct git_transport_data *data = xcalloc(1, sizeof(*data));
--
1.5.3.rc1.16.g9d6f-dirty
reply other threads:[~2007-07-17 22:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.64.0707172349360.14781@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
/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).