Subject: Re: [PATCH 12/17] odb: trivial refactorings to get rid of `the_repository`

From: Patrick Steinhardt <[email-masked]>
Date: Fri, 9 May 2025 13:25:34 +0200

On Wed, May 07, 2025 at 09:38:52AM -0700, Junio C Hamano wrote:
> Derrick Stolee <[email-masked]> writes:
> 
> > On 5/6/25 7:09 AM, Patrick Steinhardt wrote:
> >> All of the external functions provided by the object database subsystem
> >> don't depend on `the_repository` anymore, but some internal functions
> >> still do. Refactor those cases by plumbing through the repository that
> >> owns the object database.
> >> This change allows us to get rid of the
> >> `USE_THE_REPOSITORY_VARIABLE`
> >> preprocessor define.
> >
> >> --- a/odb.c
> >> +++ b/odb.c
> >> @@ -1,5 +1,3 @@
> >> -#define USE_THE_REPOSITORY_VARIABLE
> >> -
> >
> > Very satisfying! Thanks,
> 
> Yes, nice outcome.  I looked at the resulting odb.c and was a bit
> unhappy to see that we still need to pass "struct repository *"
> (instead of "struct object_database *") around.  But that is not
> because we assume we can get to an odb via repo, but primarily
> because repo has many things like config access and hash-algo that
> we rely on, so it is perfectly OK.
> 
> At some places, where we pass odb around, we can and do go from it
> to its repository (e.g. odb->repo->hash_algo), which was what I am
> expecting to see more of in the future.

Yup. Over time I very much have the intent to reduce the reliance on
`odb->repo` even further. Ideally, the object database should have all
info, or at least almost all of it, to function correctly.

Patrick