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 inconsistency so that we can always assume the pack info to be
populated when reading object info from a pack.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2026-01-07 14:08:03 +01:00 committed by Junio C Hamano
parent 56be11f501
commit 03d894e23c

View File

@ -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;
}