From: Justin Tobler Date: Thu, 15 Jan 2026 18:31:13 GMT Subject: Re: [PATCH 03/14] object-file: extract function to read object info from path Message-ID: In-Reply-To: <20260115-pks-odb-for-each-object-v1-3-5418a91d5d99@pks.im> On 26/01/15 12:04PM, Patrick Steinhardt wrote: > Extract a new function that allows us to read object info for a specific > loose object via a user-supplied path. This function will be used in a > subsequent commit. Ok, I assume that the new function we are talking about here is read_object_info_from_path(). This new function does the same thing as the previous version of odb_source_loose_read_object_info(), but now requires the path to be provided. > Note that this also allows us to drop `stat_loose_object()`, which is > a simple wrapper around `odb_loose_path()` plus lstat(3p). > > Signed-off-by: Patrick Steinhardt > --- > object-file.c | 39 ++++++++++++++++----------------------- > 1 file changed, 16 insertions(+), 23 deletions(-) > > diff --git a/object-file.c b/object-file.c > index 8fa461dd59..a651129426 100644 > --- a/object-file.c > +++ b/object-file.c [snip] > @@ -455,7 +438,7 @@ int odb_source_loose_read_object_info(struct odb_source *source, > goto out; > } > > - fd = open_loose_object(source->loose, oid, &path); > + fd = git_open(path); Here we already have the path, so there is no need to invoke odb_loose_path() again via open_loose_object(). We can instead call git_open() directly. Looks good. If I understand correctly, even before this change the path was already available so using open_loose_object() here was already redundant. > if (fd < 0) { > if (errno != ENOENT) > error_errno(_("unable to open loose object %s"), oid_to_hex(oid)); > @@ -534,6 +517,16 @@ int odb_source_loose_read_object_info(struct odb_source *source, > return ret; > } > > +int odb_source_loose_read_object_info(struct odb_source *source, > + const struct object_id *oid, > + struct object_info *oi, > + unsigned flags) > +{ > + static struct strbuf buf = STRBUF_INIT; > + odb_loose_path(source, &buf, oid); > + return read_object_info_from_path(source, buf.buf, oid, oi, flags); Looks good. -Justin