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>
Patrick Steinhardt committed
Jan 12, 2026 at 10:00 UTC
57c168dc3824f1aaad553f90f55fdc86b75de561
1 file changed
+14
-17
packfile.c
+14
-17
@@ -1657,6 +1657,20 @@ int packed_object_info(struct repository *r, struct packed_git *p,
1657
}
1658
1659
oi->whence = OI_PACKED;
1660
+ oi->u.packed.offset = obj_offset;
1661
+ oi->u.packed.pack = p;
1662
+
1663
+ switch (type) {
1664
+ case OBJ_REF_DELTA:
1665
+ oi->u.packed.type = PACKED_OBJECT_TYPE_REF_DELTA;
1666
+ break;
1667
+ case OBJ_OFS_DELTA:
1668
+ oi->u.packed.type = PACKED_OBJECT_TYPE_OFS_DELTA;
1669
+ break;
1670
+ default:
1671
+ oi->u.packed.type = PACKED_OBJECT_TYPE_FULL;
1672
+ break;
1673
+ }
1674
1675
out:
1676
unuse_pack(&w_curs);
@@ -2156,23 +2170,6 @@ int packfile_store_read_object_info(struct packfile_store *store,
2170
return -1;
2171
}
2172
2159
- if (oi->whence == OI_PACKED) {
2160
- oi->u.packed.offset = e.offset;
2161
- oi->u.packed.pack = e.p;
2162
-
2163
- switch (rtype) {
2164
- case OBJ_REF_DELTA:
2165
- oi->u.packed.type = PACKED_OBJECT_TYPE_REF_DELTA;
2166
- break;
2167
- case OBJ_OFS_DELTA:
2168
- oi->u.packed.type = PACKED_OBJECT_TYPE_OFS_DELTA;
2169
- break;
2170
- default:
2171
- oi->u.packed.type = PACKED_OBJECT_TYPE_FULL;
2172
- break;
2173
- }
2174
- }
2175
-
2173
return 0;
2174
}
2175