packfile: inline custom read_object()
When the pack code was split into its own file[1], it got a copy of the static read_object() function. But there's only one caller here, so we could just inline it. And it's worth doing so, as the name read_object() invites comparisons to the public read_object_file(), but the two don't behave quite the same. [1] The move happened over several commits, but the relevant one here is f1d8130be0 (pack: move clear_delta_base_cache(), packed_object_info(), unpack_entry(), 2017-08-18). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jan 7, 2023 at 08:50 UTC
c2f32bef9cbed13f21b2308cc3c02158c338f70f
1 file changed
+9
-17
packfile.c
+9
-17
@@ -1650,22 +1650,6 @@ struct unpack_entry_stack_ent {
1650
unsigned long size;
1651
};
1652
1653
-static void *read_object(struct repository *r,
1654
- const struct object_id *oid,
1655
- enum object_type *type,
1656
- unsigned long *size)
1657
-{
1658
- struct object_info oi = OBJECT_INFO_INIT;
1659
- void *content;
1660
- oi.typep = type;
1661
- oi.sizep = size;
1662
- oi.contentp = &content;
1663
-
1664
- if (oid_object_info_extended(r, oid, &oi, 0) < 0)
1665
- return NULL;
1666
- return content;
1667
-}
1668
-
1653
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1654
enum object_type *final_type, unsigned long *final_size)
1655
{
@@ -1798,6 +1782,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1782
uint32_t pos;
1783
struct object_id base_oid;
1784
if (!(offset_to_pack_pos(p, obj_offset, &pos))) {
1785
+ struct object_info oi = OBJECT_INFO_INIT;
1786
+
1787
nth_packed_object_id(&base_oid, p,
1788
pack_pos_to_index(p, pos));
1789
error("failed to read delta base object %s"
@@ -1805,7 +1791,13 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
1791
oid_to_hex(&base_oid), (uintmax_t)obj_offset,
1792
p->pack_name);
1793
mark_bad_packed_object(p, &base_oid);
1808
- base = read_object(r, &base_oid, &type, &base_size);
1794
+
1795
+ oi.typep = &type;
1796
+ oi.sizep = &base_size;
1797
+ oi.contentp = &base;
1798
+ if (oid_object_info_extended(r, &base_oid, &oi, 0) < 0)
1799
+ base = NULL;
1800
+
1801
external_base = base;
1802
}
1803
}