Skip to content

Commit c2f32be

Browse files
peffgitster
authored andcommitted
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 f1d8130 (pack: move clear_delta_base_cache(), packed_object_info(), unpack_entry(), 2017-08-18). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ba05cf commit c2f32be

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

packfile.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,22 +1650,6 @@ struct unpack_entry_stack_ent {
16501650
unsigned long size;
16511651
};
16521652

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-
16691653
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16701654
enum object_type *final_type, unsigned long *final_size)
16711655
{
@@ -1798,14 +1782,22 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
17981782
uint32_t pos;
17991783
struct object_id base_oid;
18001784
if (!(offset_to_pack_pos(p, obj_offset, &pos))) {
1785+
struct object_info oi = OBJECT_INFO_INIT;
1786+
18011787
nth_packed_object_id(&base_oid, p,
18021788
pack_pos_to_index(p, pos));
18031789
error("failed to read delta base object %s"
18041790
" at offset %"PRIuMAX" from %s",
18051791
oid_to_hex(&base_oid), (uintmax_t)obj_offset,
18061792
p->pack_name);
18071793
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+
18091801
external_base = base;
18101802
}
18111803
}

0 commit comments

Comments
 (0)