diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-07-17 06:56:39 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-07-16 22:16:17 -0700 |
| commit | d81712ce65f7ee59ce88c8b74f09b6e6456a6f3c (patch) | |
| tree | c4489f5d836c944447042afe0b1c364b4bb81c4a /object-file.c | |
| parent | object-file: remove declaration for `for_each_file_in_obj_subdir()` (diff) | |
| download | git-d81712ce65f7ee59ce88c8b74f09b6e6456a6f3c.tar.gz git-d81712ce65f7ee59ce88c8b74f09b6e6456a6f3c.zip | |
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>
Diffstat (limited to 'object-file.c')
| -rw-r--r-- | object-file.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/object-file.c b/object-file.c index bd93f17dcf..b894379d22 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, each_loose_object_fn obj_cb, each_loose_cruft_fn cruft_cb, each_loose_subdir_fn subdir_cb, @@ -1397,11 +1397,10 @@ int for_each_loose_file_in_objdir(const char *path, struct strbuf buf = STRBUF_INIT; int r; - strbuf_addstr(&buf, path); + strbuf_addstr(&buf, source->path); for (int i = 0; i < 256; i++) { - r = for_each_file_in_obj_subdir(i, &buf, the_repository->hash_algo, - obj_cb, cruft_cb, - subdir_cb, data); + r = for_each_file_in_obj_subdir(i, &buf, source->odb->repo->hash_algo, + obj_cb, cruft_cb, subdir_cb, data); if (r) break; } @@ -1410,14 +1409,15 @@ int for_each_loose_file_in_objdir(const char *path, return r; } -int for_each_loose_object(each_loose_object_fn cb, void *data, +int for_each_loose_object(struct object_database *odb, + each_loose_object_fn cb, void *data, enum for_each_object_flags flags) { struct odb_source *source; - odb_prepare_alternates(the_repository->objects); - for (source = the_repository->objects->sources; source; source = source->next) { - int r = for_each_loose_file_in_objdir(source->path, cb, NULL, + odb_prepare_alternates(odb); + for (source = odb->sources; source; source = source->next) { + int r = for_each_loose_file_in_source(source, cb, NULL, NULL, data); if (r) return r; |
