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>
This commit is contained in:

committed by
Junio C Hamano

parent
dc7fb4f72c
commit
8378c9d27b
@ -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);
|
||||
|
Reference in New Issue
Block a user