diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-17 10:18:49 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-17 10:33:38 -0700 |
commit | 8378c9d27bace61d3fb238259604045a8997387b (patch) | |
tree | a8e4b9f0dbb91c0d4fbb3e8e05c08afd87e38476 /replace-object.c | |
parent | dc7fb4f72c2e39ffbb98aee55ad7ea4c3f8e12fc (diff) |
refs: convert iteration over replace refs to accept ref store
The function `for_each_replace_ref()` is a bit of an oddball across the
refs interfaces as it accepts a pointer to the repository instead of a
pointer to the ref store. The only reason for us to accept a repository
is so that we can eventually pass it back to the callback function that
the caller has provided. This is somewhat arbitrary though, as callers
that need the repository can instead make it accessible via the callback
payload.
Refactor the function to instead accept the ref store and adjust callers
accordingly. This allows us to get rid of some of the boilerplate that
we had to carry to pass along the repository and brings us in line with
the other functions that iterate through refs.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'replace-object.c')
-rw-r--r-- | replace-object.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/replace-object.c b/replace-object.c index 523215589d..73f5acbcd9 100644 --- a/replace-object.c +++ b/replace-object.c @@ -8,12 +8,13 @@ #include "repository.h" #include "commit.h" -static int register_replace_ref(struct repository *r, - const char *refname, +static int register_replace_ref(const char *refname, const struct object_id *oid, int flag UNUSED, - void *cb_data UNUSED) + void *cb_data) { + struct repository *r = cb_data; + /* Get sha1 from refname */ const char *slash = strrchr(refname, '/'); const char *hash = slash ? slash + 1 : refname; @@ -50,7 +51,8 @@ void prepare_replace_object(struct repository *r) xmalloc(sizeof(*r->objects->replace_map)); oidmap_init(r->objects->replace_map, 0); - for_each_replace_ref(r, register_replace_ref, NULL); + refs_for_each_replace_ref(get_main_ref_store(r), + register_replace_ref, r); r->objects->replace_map_initialized = 1; pthread_mutex_unlock(&r->objects->replace_mutex); |