Subject: Re: [PATCH 13/19] object-file: get rid of `the_repository` in loose object iterators

From: Toon Claes <[email-masked]>
Date: Thu, 10 Jul 2025 20:41:28 +0200

Patrick Steinhardt <[email-masked]> writes:

> The iterators for loose objects still rely on `the_repository`. Refactor
> them:
>
>   - `for_each_loose_file_in_objdir()` is refactored so that the caller
>     is now expected to pass an `odb_source` as parameter instead of the
>     path to that source. Furthermore, it is renamed accordingly to
>     `for_each_loose_file_in_source()`.
>
>   - `for_each_loose_object()` is refactored to take in an object
>     database now and calls the above function in a loop.
>
> This allows us to get rid of the global dependency.
>
> Adjust callers accordingly.
>
> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---
>  builtin/cat-file.c      |  2 +-
>  builtin/count-objects.c |  2 +-
>  builtin/fsck.c          | 14 ++++++++------
>  builtin/gc.c            | 10 ++++------
>  builtin/pack-objects.c  |  5 ++---
>  builtin/prune.c         |  2 +-
>  object-file.c           | 18 +++++++++---------
>  object-file.h           |  5 +++--
>  prune-packed.c          |  2 +-
>  reachable.c             |  2 +-
>  10 files changed, 31 insertions(+), 31 deletions(-)
>

[snip]

> diff --git a/object-file.c b/object-file.c
> index bd93f17dcfe..b894379d22c 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -1388,7 +1388,7 @@ static int for_each_file_in_obj_subdir(unsigned int subdir_nr,
>  	return r;
>  }
>  
> -int for_each_loose_file_in_objdir(const char *path,
> +int for_each_loose_file_in_source(struct odb_source *source,

I really enjoy seeing how your plan comes together here. So much nicer
to not pass in the path directly.

-- 
Cheers,
Toon