There is only one type of delta with pack v4. The base reference encoding already handles either an offset (via the pack index) or a literal SHA1. We assume in the literal SHA1 case that the object lives in the same pack, just like with previous pack versions. Signed-off-by: Nicolas Pitre <nico@xxxxxxxxxxx> --- sha1_file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sha1_file.c b/sha1_file.c index 67eb903..f3bfa28 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1686,7 +1686,19 @@ static off_t get_delta_base(struct packed_git *p, * that is assured. An OFS_DELTA longer than the hash size * is stupid, as then a REF_DELTA would be smaller to store. */ - if (type == OBJ_OFS_DELTA) { + if (p->version >= 4) { + if (base_info[0] != 0) { + const unsigned char *cp = base_info; + unsigned int base_index = decode_varint(&cp); + if (!base_index || base_index - 1 >= p->num_objects) + return 0; /* out of bounds */ + *curpos += cp - base_info; + base_offset = nth_packed_object_offset(p, base_index - 1); + } else { + base_offset = find_pack_entry_one(base_info+1, p); + *curpos += 21; + } + } else if (type == OBJ_OFS_DELTA) { const unsigned char *cp = base_info; base_offset = decode_varint(&cp); base_offset = delta_obj_offset - base_offset; -- 1.8.4.38.g317e65b -- 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