Re: [PATCH 15/19] object-file: get rid of `the_repository` in `force_object_loose()`
- From
Toon Claes <toon@iotcl.com>
- Date
- Jul 15, 2025, 11:36 UTC
- Message-ID
- <87wm89bs91.fsf@iotcl.com>
- In-Reply-To
- <aHYya4PKoWT3-wPQ@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 9 quoted lines
> On Fri, Jul 11, 2025 at 05:38:35AM -0500, Karthik Nayak wrote: >> >> Q: Since it exists in the packed form, won't the check always return >> true? > > I'm not quite sure I understand the question. This function is about > _ensuring_ that the object exists in its loose format. So if it only > exists in a packfile, it will be written in its loose format. If it > already exists as a loose object, nothing happens.
The way I understand Karthik's question: We check all the odb->sources for the object, so Karthik assumes (rightfully) one of the sources will have the object, and thus the function early returns.
But when I look at the implementation of has_loose_object() it eventually calls odb_loose_path() to find the object. So we check all sources, but check if it exists in loose form only.
From the commit message:
> While the check whether any such loose object exists already acts on the > whole object database, writing the loose object happens in one specific > source.
I must admit this last sentence from commit message now also makes more sense to me.
-- Cheers, Toon