Skip to content

Commit 57c168d

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 27d9486 commit 57c168d

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

packfile.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,20 @@ int packed_object_info(struct repository *r, struct packed_git *p,
16571657
}
16581658

16591659
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+
}
16601674

16611675
out:
16621676
unuse_pack(&w_curs);
@@ -2156,23 +2170,6 @@ int packfile_store_read_object_info(struct packfile_store *store,
21562170
return -1;
21572171
}
21582172

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-
21762173
return 0;
21772174
}
21782175

0 commit comments

Comments
 (0)