mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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
17
refs.h
17
refs.h
@@ -298,16 +298,6 @@ struct ref_transaction;
|
||||
typedef int each_ref_fn(const char *refname,
|
||||
const struct object_id *oid, int flags, void *cb_data);
|
||||
|
||||
/*
|
||||
* The same as each_ref_fn, but also with a repository argument that
|
||||
* contains the repository associated with the callback.
|
||||
*/
|
||||
typedef int each_repo_ref_fn(struct repository *r,
|
||||
const char *refname,
|
||||
const struct object_id *oid,
|
||||
int flags,
|
||||
void *cb_data);
|
||||
|
||||
/*
|
||||
* The following functions invoke the specified callback function for
|
||||
* each reference indicated. If the function ever returns a nonzero
|
||||
@@ -329,6 +319,8 @@ int refs_for_each_branch_ref(struct ref_store *refs,
|
||||
each_ref_fn fn, void *cb_data);
|
||||
int refs_for_each_remote_ref(struct ref_store *refs,
|
||||
each_ref_fn fn, void *cb_data);
|
||||
int refs_for_each_replace_ref(struct ref_store *refs,
|
||||
each_ref_fn fn, void *cb_data);
|
||||
|
||||
/*
|
||||
* references matching any pattern in "exclude_patterns" are omitted from the
|
||||
@@ -353,11 +345,6 @@ int refs_for_each_fullref_in_prefixes(struct ref_store *refs,
|
||||
const char **exclude_patterns,
|
||||
each_ref_fn fn, void *cb_data);
|
||||
|
||||
/**
|
||||
* iterate refs from the respective area.
|
||||
*/
|
||||
int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data);
|
||||
|
||||
/* iterates all refs that match the specified glob pattern. */
|
||||
int refs_for_each_glob_ref(struct ref_store *refs, each_ref_fn fn,
|
||||
const char *pattern, void *cb_data);
|
||||
|
||||
Reference in New Issue
Block a user