From: Patrick Steinhardt Date: Thu, 18 Dec 2025 10:54:16 +0000 (+0100) Subject: packfile: always populate pack-specific info when reading object info X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd110e96f005938822351bc47fc0985bbe05175e;p=thirdparty%2Fgit.git packfile: always populate pack-specific info when reading object info When reading object information via `packed_object_info()` we may not populate the object info's packfile-specific fields. This leads to inconsistent object info depending on whether the info was populated via `packfile_store_read_object_info()` or `packed_object_info()`. Fix this inconsistecny so that we can always assume the pack info to be populated when reading object info from a pack. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/packfile.c b/packfile.c index cc797b2b6a..f7c33a2f77 100644 --- a/packfile.c +++ b/packfile.c @@ -1657,6 +1657,20 @@ int packed_object_info(struct repository *r, struct packed_git *p, } oi->whence = OI_PACKED; + oi->u.packed.offset = obj_offset; + oi->u.packed.pack = p; + + switch (type) { + case OBJ_REF_DELTA: + oi->u.packed.type = PACKED_OBJECT_TYPE_REF_DELTA; + break; + case OBJ_OFS_DELTA: + oi->u.packed.type = PACKED_OBJECT_TYPE_OFS_DELTA; + break; + default: + oi->u.packed.type = PACKED_OBJECT_TYPE_FULL; + break; + } out: unuse_pack(&w_curs); @@ -2156,23 +2170,6 @@ int packfile_store_read_object_info(struct packfile_store *store, return -1; } - if (oi->whence == OI_PACKED) { - oi->u.packed.offset = e.offset; - oi->u.packed.pack = e.p; - - switch (rtype) { - case OBJ_REF_DELTA: - oi->u.packed.type = PACKED_OBJECT_TYPE_REF_DELTA; - break; - case OBJ_OFS_DELTA: - oi->u.packed.type = PACKED_OBJECT_TYPE_OFS_DELTA; - break; - default: - oi->u.packed.type = PACKED_OBJECT_TYPE_FULL; - break; - } - } - return 0; }