Skip to content

Commit 34728d7

Browse files
peffgitster
authored andcommitted
streaming: inline call to read_object_file_extended()
The open_istream_incore() function is the only direct user of read_object_file_extended(), and the only caller which unsets the lookup_replace flag. Since read_object_file_extended() is now just a thin wrapper around oid_object_info_extended(), let's inline the call. That will let us simplify read_object_file_extended() in the next patch. The inlined version here is a few more lines because of the query setup, but it's much more flexible, since we can pass (or omit) any flags we want. Note the updated comment in the istream struct definition. It was already slightly wrong (we never called read_object(); it has been read_object_file_extended() since day one), but should now be accurate. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b25562e commit 34728d7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

streaming.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct git_istream {
3838

3939
union {
4040
struct {
41-
char *buf; /* from read_object() */
41+
char *buf; /* from oid_object_info_extended() */
4242
unsigned long read_ptr;
4343
} incore;
4444

@@ -388,12 +388,17 @@ static ssize_t read_istream_incore(struct git_istream *st, char *buf, size_t sz)
388388
static int open_istream_incore(struct git_istream *st, struct repository *r,
389389
const struct object_id *oid, enum object_type *type)
390390
{
391-
st->u.incore.buf = read_object_file_extended(r, oid, type, &st->size, 0);
391+
struct object_info oi = OBJECT_INFO_INIT;
392+
392393
st->u.incore.read_ptr = 0;
393394
st->close = close_istream_incore;
394395
st->read = read_istream_incore;
395396

396-
return st->u.incore.buf ? 0 : -1;
397+
oi.typep = type;
398+
oi.sizep = &st->size;
399+
oi.contentp = (void **)&st->u.incore.buf;
400+
return oid_object_info_extended(r, oid, &oi,
401+
OBJECT_INFO_DIE_IF_CORRUPT);
397402
}
398403

399404
/*****************************************************************************

0 commit comments

Comments
 (0)