aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-01 14:22:21 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-01 14:46:36 -0700
commit798c661ce39f7d5297fa7ea8928ae464b6d5dd95 (patch)
treed3e3e7263db4180d4b71ce7fd87b76a1e0004119 /builtin
parentc44185f6c10fb2d306efe505112982a7c3b93789 (diff)
downloadgit-798c661ce39f7d5297fa7ea8928ae464b6d5dd95.tar.xz
odb: get rid of `the_repository` in `for_each()` functions
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. Rename the functions accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/count-objects.c2
-rw-r--r--builtin/receive-pack.c3
-rw-r--r--builtin/submodule--helper.c3
3 files changed, 5 insertions, 3 deletions
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 58e0af433d..f687647931 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -159,7 +159,7 @@ int cmd_count_objects(int argc,
printf("prune-packable: %lu\n", packed_loose);
printf("garbage: %lu\n", garbage);
printf("size-garbage: %s\n", garbage_buf.buf);
- foreach_alt_odb(print_alternate, NULL);
+ odb_for_each_alternate(the_repository->objects, print_alternate, NULL);
strbuf_release(&loose_buf);
strbuf_release(&pack_buf);
strbuf_release(&garbage_buf);
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 0f5958c4a6..7ea273d93e 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -359,7 +359,8 @@ static void write_head_info(void)
refs_for_each_fullref_in(get_main_ref_store(the_repository), "",
exclude_patterns, show_ref_cb, &seen);
- for_each_alternate_ref(show_one_alternate_ref, &seen);
+ odb_for_each_alternate_ref(the_repository->objects,
+ show_one_alternate_ref, &seen);
oidset_clear(&seen);
strvec_clear(&excludes_vector);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 84f7fa5342..7ca483cab5 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1668,7 +1668,8 @@ static void prepare_possible_alternates(const char *sm_name,
die(_("Value '%s' for submodule.alternateErrorStrategy is not recognized"), error_strategy);
if (!strcmp(sm_alternate, "superproject"))
- foreach_alt_odb(add_possible_reference_from_superproject, &sas);
+ odb_for_each_alternate(the_repository->objects,
+ add_possible_reference_from_superproject, &sas);
else if (!strcmp(sm_alternate, "no"))
; /* do nothing */
else