@@ -1414,6 +1414,7 @@ int head_ref(each_ref_fn fn, void *cb_data)
struct ref_iterator *refs_ref_iterator_begin(
struct ref_store *refs,
const char *prefix, int trim,
+ struct repository *repo,
enum do_for_each_ref_flags flags)
{
struct ref_iterator *iter;
@@ -1429,7 +1430,7 @@ struct ref_iterator *refs_ref_iterator_begin(
}
}
- iter = refs->be->iterator_begin(refs, prefix, flags);
+ iter = refs->be->iterator_begin(refs, prefix, repo, flags);
/*
* `iterator_begin()` already takes care of prefix, but we
@@ -1464,7 +1465,7 @@ static int do_for_each_repo_ref(struct repository *r, const char *prefix,
if (!refs)
return 0;
- iter = refs_ref_iterator_begin(refs, prefix, trim, flags);
+ iter = refs_ref_iterator_begin(refs, prefix, trim, r, flags);
return do_for_each_repo_ref_iterator(r, iter, fn, cb_data);
}
@@ -1495,7 +1496,7 @@ static int do_for_each_ref(struct ref_store *refs, const char *prefix,
if (!refs)
return 0;
- iter = refs_ref_iterator_begin(refs, prefix, trim, flags);
+ iter = refs_ref_iterator_begin(refs, prefix, trim, the_repository, flags);
return do_for_each_repo_ref_iterator(the_repository, iter,
do_for_each_ref_helper, &hp);
@@ -2260,7 +2261,7 @@ int refs_verify_refname_available(struct ref_store *refs,
strbuf_addstr(&dirname, refname + dirname.len);
strbuf_addch(&dirname, '/');
- iter = refs_ref_iterator_begin(refs, dirname.buf, 0,
+ iter = refs_ref_iterator_begin(refs, dirname.buf, 0, the_repository,
DO_FOR_EACH_INCLUDE_BROKEN);
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
if (skip &&
@@ -224,11 +224,11 @@ static struct ref_iterator_vtable debug_ref_iterator_vtable = {
static struct ref_iterator *
debug_ref_iterator_begin(struct ref_store *ref_store, const char *prefix,
- unsigned int flags)
+ struct repository *repo, unsigned int flags)
{
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
struct ref_iterator *res =
- drefs->refs->be->iterator_begin(drefs->refs, prefix, flags);
+ drefs->refs->be->iterator_begin(drefs->refs, prefix, repo, flags);
struct debug_ref_iterator *diter = xcalloc(1, sizeof(*diter));
base_ref_iterator_init(&diter->base, &debug_ref_iterator_vtable, 1);
diter->iter = res;
@@ -798,7 +798,7 @@ static struct ref_iterator_vtable files_ref_iterator_vtable = {
static struct ref_iterator *files_ref_iterator_begin(
struct ref_store *ref_store,
- const char *prefix, unsigned int flags)
+ const char *prefix, struct repository *repo, unsigned int flags)
{
struct files_ref_store *refs;
struct ref_iterator *loose_iter, *packed_iter, *overlay_iter;
@@ -844,6 +844,7 @@ static struct ref_iterator *files_ref_iterator_begin(
*/
packed_iter = refs_ref_iterator_begin(
refs->packed_ref_store, prefix, 0,
+ repo,
DO_FOR_EACH_INCLUDE_BROKEN);
overlay_iter = overlay_ref_iterator_begin(loose_iter, packed_iter);
@@ -913,7 +913,7 @@ static struct ref_iterator_vtable packed_ref_iterator_vtable = {
static struct ref_iterator *packed_ref_iterator_begin(
struct ref_store *ref_store,
- const char *prefix, unsigned int flags)
+ const char *prefix, struct repository *repo, unsigned int flags)
{
struct packed_ref_store *refs;
struct snapshot *snapshot;
@@ -1135,8 +1135,14 @@ static int write_with_updates(struct packed_ref_store *refs,
* of the lists each time through the loop. When the current
* list of refs is exhausted, set iter to NULL. When the list
* of updates is exhausted, leave i set to updates->nr.
+ *
+ * Note that the repository does not matter since
+ * DO_FOR_EACH_INCLUDE_BROKEN means that we do not access any objects,
+ * but the_repository here makes the most sense because we only support
+ * writing refs to the main repository.
*/
iter = packed_ref_iterator_begin(&refs->base, "",
+ the_repository,
DO_FOR_EACH_INCLUDE_BROKEN);
if ((ok = ref_iterator_advance(iter)) != ITER_OK)
iter = NULL;
@@ -382,6 +382,7 @@ int is_empty_ref_iterator(struct ref_iterator *ref_iterator);
struct ref_iterator *refs_ref_iterator_begin(
struct ref_store *refs,
const char *prefix, int trim,
+ struct repository *repo,
enum do_for_each_ref_flags flags);
/*
@@ -583,7 +584,7 @@ typedef int copy_ref_fn(struct ref_store *ref_store,
*/
typedef struct ref_iterator *ref_iterator_begin_fn(
struct ref_store *ref_store,
- const char *prefix, unsigned int flags);
+ const char *prefix, struct repository *repo, unsigned int flags);
/* reflog functions */
In preparation for the next 2 patches that adds (partial) support for arbitrary repositories, plumb a repository parameter in all functions that create iterators. There are no changes to program logic. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> --- refs.c | 9 +++++---- refs/debug.c | 4 ++-- refs/files-backend.c | 3 ++- refs/packed-backend.c | 8 +++++++- refs/refs-internal.h | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-)