X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-unpack-objects.c;h=50e07faa12f495b3270e1446573b88a255336877;hb=803d5158123346229d71de53818920efbc88ca0f;hp=1e51865c52231e80cfdbbb19c8b6fa86ee8855d2;hpb=bd6ba4d28bf75b0857b3c81aa8bca8e454d9e79e;p=git.git diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index 1e51865c5..50e07faa1 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,18 @@ 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); +} + /* * Make sure at least "min" bytes are available in the buffer, and * return the pointer to the buffer. @@ -189,6 +202,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, void *delta_data, *base; unsigned long base_size; unsigned char base_sha1[20]; + struct object *obj; if (type == OBJ_REF_DELTA) { hashcpy(base_sha1, fill(20)); @@ -252,6 +266,15 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, } } + 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",