refs: add method iterator_begin

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 4, 2016 at 18:08 UTC 1a769003c19c106063f4bf474b0d7ef56be8df25
3 files changed +15 -14
refs.c
+1 -1
@@ -1157,7 +1157,7 @@ static int do_for_each_ref(const char *submodule, const char *prefix,
1157 if (!refs)
1158 return 0;
1159
1160 - iter = files_ref_iterator_begin(refs, prefix, flags);
1160 + iter = refs->be->iterator_begin(refs, prefix, flags);
1161 iter = prefix_ref_iterator_begin(iter, prefix, trim);
1162
1163 return do_for_each_ref_iterator(iter, fn, cb_data);
refs/files-backend.c
+2 -1
@@ -1862,7 +1862,7 @@ static struct ref_iterator_vtable files_ref_iterator_vtable = {
1862 files_ref_iterator_abort
1863 };
1864
1865 -struct ref_iterator *files_ref_iterator_begin(
1865 +static struct ref_iterator *files_ref_iterator_begin(
1866 struct ref_store *ref_store,
1867 const char *prefix, unsigned int flags)
1868 {
@@ -4044,6 +4044,7 @@ struct ref_storage_be refs_be_files = {
4044 files_peel_ref,
4045 files_create_symref,
4046
4047 + files_ref_iterator_begin,
4048 files_read_raw_ref,
4049 files_verify_refname_available
4050 };
refs/refs-internal.h
+12 -12
@@ -404,18 +404,6 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
404 const char *prefix,
405 int trim);
406
407 -struct ref_store;
408 -
409 -/*
410 - * Iterate over the packed and loose references in the specified
411 - * ref_store that are within find_containing_dir(prefix). If prefix is
412 - * NULL or the empty string, iterate over all references in the
413 - * submodule.
414 - */
415 -struct ref_iterator *files_ref_iterator_begin(struct ref_store *ref_store,
416 - const char *prefix,
417 - unsigned int flags);
418 -
407 /*
408 * Iterate over the references in the main ref_store that have a
409 * reflog. The paths within a directory are iterated over in arbitrary
@@ -488,6 +476,8 @@ int do_for_each_ref_iterator(struct ref_iterator *iter,
476
477 /* refs backends */
478
479 +struct ref_store;
480 +
481 /*
482 * Initialize the ref_store for the specified submodule, or for the
483 * main repository if submodule == NULL. These functions should call
@@ -508,6 +498,15 @@ typedef int create_symref_fn(struct ref_store *ref_store,
498 const char *refs_heads_master,
499 const char *logmsg);
500
501 +/*
502 + * Iterate over the references in the specified ref_store that are
503 + * within find_containing_dir(prefix). If prefix is NULL or the empty
504 + * string, iterate over all references in the submodule.
505 + */
506 +typedef struct ref_iterator *ref_iterator_begin_fn(
507 + struct ref_store *ref_store,
508 + const char *prefix, unsigned int flags);
509 +
510 /*
511 * Read a reference from the specified reference store, non-recursively.
512 * Set type to describe the reference, and:
@@ -566,6 +565,7 @@ struct ref_storage_be {
565 peel_ref_fn *peel_ref;
566 create_symref_fn *create_symref;
567
568 + ref_iterator_begin_fn *iterator_begin;
569 read_raw_ref_fn *read_raw_ref;
570 verify_refname_available_fn *verify_refname_available;
571 };