object-file: get rid of the_repository in loose object iterators

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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-07-17 06:56:39 +02:00
committed by Junio C Hamano
parent 83439299f1
commit d81712ce65
10 changed files with 31 additions and 31 deletions

View File

@@ -86,7 +86,7 @@ typedef int each_loose_cruft_fn(const char *basename,
typedef int each_loose_subdir_fn(unsigned int nr,
const char *path,
void *data);
int for_each_loose_file_in_objdir(const char *path,
int for_each_loose_file_in_source(struct odb_source *source,
each_loose_object_fn obj_cb,
each_loose_cruft_fn cruft_cb,
each_loose_subdir_fn subdir_cb,
@@ -99,7 +99,8 @@ int for_each_loose_file_in_objdir(const char *path,
*
* Any flags specific to packs are ignored.
*/
int for_each_loose_object(each_loose_object_fn, void *,
int for_each_loose_object(struct object_database *odb,
each_loose_object_fn, void *,
enum for_each_object_flags flags);