Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/pack-objects.c | 28 +++++++++++++++++++++++++--- packv4-parse.h | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 63c9b9e..ac25973 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -19,6 +19,8 @@ #include "streaming.h" #include "thread-utils.h" #include "packv4-create.h" +#include "packv4-parse.h" +#include "varint.h" static const char *pack_usage[] = { N_("git pack-objects --stdout [options...] [< ref-list | < object-list]"), @@ -1397,9 +1399,14 @@ static void check_object(struct object_entry *entry) * We want in_pack_type even if we do not reuse delta * since non-delta representations could still be reused. */ - used = unpack_object_header_buffer(buf, avail, - &entry->in_pack_type, - &entry->size); + if (p->version < 4) + used = unpack_object_header_buffer(buf, avail, + &entry->in_pack_type, + &entry->size); + else + used = pv4_unpack_object_header_buffer(buf, avail, + &entry->in_pack_type, + &entry->size); if (used == 0) goto give_up; @@ -1417,7 +1424,22 @@ static void check_object(struct object_entry *entry) goto give_up; unuse_pack(&w_curs); return; + case OBJ_PV4_COMMIT: + case OBJ_PV4_TREE: + entry->type = entry->in_pack_type - 8; + entry->in_pack_header_size = used; + unuse_pack(&w_curs); + return; case OBJ_REF_DELTA: + if (p->version == 4) { + const unsigned char *sha1, *cp; + cp = buf + used; + sha1 = get_sha1ref(p, &cp); + entry->in_pack_header_size = cp - buf;; + if (reuse_delta && !entry->preferred_base) + base_ref = sha1; + break; + } if (reuse_delta && !entry->preferred_base) base_ref = use_pack(p, &w_curs, entry->in_pack_offset + used, NULL); diff --git a/packv4-parse.h b/packv4-parse.h index 52f52f5..d674a3f 100644 --- a/packv4-parse.h +++ b/packv4-parse.h @@ -14,6 +14,8 @@ unsigned long pv4_unpack_object_header_buffer(const unsigned char *base, unsigned long len, enum object_type *type, unsigned long *sizep); +const unsigned char *get_sha1ref(struct packed_git *p, + const unsigned char **bufp); void *pv4_get_commit(struct packed_git *p, struct pack_window **w_curs, off_t offset, unsigned long size); -- 1.8.2.82.gc24b958 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html