From: Martin Koegler <mkoegler@auto.tuwien.ac.at>
To: git@vger.kernel.org
Cc: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Subject: [PATCH 07/10] unpack-object: cache for non written objects
Date: Mon, 25 Feb 2008 22:54:57 +0100 [thread overview]
Message-ID: <12039765002534-git-send-email-mkoegler@auto.tuwien.ac.at> (raw)
In-Reply-To: <12039765001192-git-send-email-mkoegler@auto.tuwien.ac.at>
Preventing objects with broken links entering the repository
means, that write of some objects must be delayed.
This patch adds a cache to keep the object data in memory. The delta
resolving code must also search in the cache.
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
builtin-unpack-objects.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 1e51865..f18c7e8 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -8,6 +8,7 @@
#include "tag.h"
#include "tree.h"
#include "progress.h"
+#include "decorate.h"
static int dry_run, quiet, recover, has_errors;
static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
@@ -18,6 +19,28 @@ static unsigned int offset, len;
static off_t consumed_bytes;
static SHA_CTX ctx;
+struct obj_buffer {
+ char *buffer;
+ unsigned long size;
+};
+
+static struct decoration obj_decorate;
+
+static struct obj_buffer *lookup_object_buffer(struct object *base)
+{
+ return lookup_decoration(&obj_decorate, base);
+}
+
+static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
+{
+ struct obj_buffer *obj;
+ obj = xcalloc(1, sizeof(struct obj_buffer));
+ obj->buffer = buffer;
+ obj->size = size;
+ if (add_decoration(&obj_decorate, object, obj))
+ die("object %s tried to add buffer twice!", sha1_to_hex(object->sha1));
+}
+
/*
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
@@ -252,6 +275,15 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
}
}
+ struct object* obj = lookup_object(base_sha1);
+ if (obj) {
+ struct obj_buffer *obj_buf = lookup_object_buffer (obj);
+ if (obj_buf) {
+ resolve_delta(nr, obj->type, obj_buf->buffer, obj_buf->size, delta_data, delta_size);
+ return;
+ }
+ }
+
base = read_sha1_file(base_sha1, &type, &base_size);
if (!base) {
error("failed to read delta-pack base object %s",
--
1.5.4.3.g3c5f
next prev parent reply other threads:[~2008-02-25 21:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 21:54 [PATCH 01/10] add generic, type aware object chain walker Martin Koegler
2008-02-25 21:54 ` [PATCH 02/10] builtin-fsck: move away from object-refs to fsck_walk Martin Koegler
2008-02-25 21:54 ` [PATCH 03/10] Remove unused object-ref code Martin Koegler
2008-02-25 21:54 ` [PATCH 04/10] builtin-fsck: reports missing parent commits Martin Koegler
2008-02-25 21:54 ` [PATCH 05/10] builtin-fsck: move common object checking code to fsck.c Martin Koegler
2008-02-25 21:54 ` [PATCH 06/10] add common fsck error printing function Martin Koegler
2008-02-25 21:54 ` Martin Koegler [this message]
2008-02-25 21:54 ` [PATCH 08/10] unpack-objects: prevent writing of inconsistent objects Martin Koegler
2008-02-25 21:54 ` [PATCH 09/10] index-pack: introduce checking mode Martin Koegler
2008-02-25 21:55 ` [PATCH 10/10] receive-pack: use strict mode for unpacking objects Martin Koegler
2008-02-26 9:19 ` [PATCH 05/10] builtin-fsck: move common object checking code to fsck.c Junio C Hamano
2008-02-26 21:35 ` Martin Koegler
2008-02-27 7:48 ` Junio C Hamano
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=12039765002534-git-send-email-mkoegler@auto.tuwien.ac.at \
--to=mkoegler@auto.tuwien.ac.at \
--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).