Subject: Re: [PATCH 09/17] odb: get rid of `the_repository` in `for_each()` functions

From: Derrick Stolee <[email-masked]>
Date: Tue, 6 May 2025 21:21:15 -0400

On 5/6/25 7:09 AM, Patrick Steinhardt wrote:
 > There are a couple of iterator-style functions that execute a callback
 > for each instance of a given set, all of which currently depend on
 > `the_repository`. Refactor them to instead take an object database as
 > parameter so that we can get rid of this dependency.
...
 > +/*
 > + * Iterate through all backends of the database and execute the provided
 > + * callback function for each of them. Stop iterating once the callback
 > + * function returns a non-zero value, in which case the value is bubbled up
 > + * from the callback.
 > + */
 > +typedef int odb_for_each_backend_fn(struct odb_backend *, void *);
 > +int odb_for_each_backend(struct object_database *odb,
 > +			 odb_for_each_backend_fn cb, void *payload);
 > +
 > +/*
 > + * Iterate through all alternative object backends of the database and yield
 > + * their respective references.
 > + */
 > +typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);
 > +void odb_for_each_alternate_ref(struct object_database *odb,
 > +				odb_for_each_alternate_ref_fn cb, void *payload);
 > +

Here's another occasion where we should be careful about how we rename
an "alternate odb". What is an "alternate ref" if we have different 'odb
backend's (or slices/shards/odbs etc.). Should we be updating the term
"alternate ref" here?

Changing 'alternate ref' would be quite difficult seeing how it is based
on the 'core.alternateRefsCommand' and 'core.alternateRefsPrefix' config
keys.

Perhaps this is motivation to keep the word 'alternate' but as a way to
differentiate the repo's odb from ones it is borrowing.

I'm sorry to nitpick so much here, but your thorough series is helping
to bring to mind all of the different aspects that are being conflated
by our current nomenclature that grew organically and is now being
carefully designed for the better.

Thanks,
-Stolee