Re: [PATCH 03/14] object-file: extract function to read object info from path
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Jan 15, 2026, 18:31 UTC
- Message-ID
- <aWkvucfZy7e2Rd6t@denethor>
- 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.
Show 12 quoted lines
> 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 <ps@pks.im> > --- > 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]
Show 6 quoted lines
> @@ -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.
Show 15 quoted lines
> 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