summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-08-20 18:24:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-21 17:22:50 (GMT)
commit4a6067cda51b592871144eb050d4673db9ad5103 (patch)
tree9feed4d4004ab45bba79a7aa04df31123c14ffbe /refs
parent1689c22c1c328e9135ed51458e9f9a5d224c5057 (diff)
downloadgit-4a6067cda51b592871144eb050d4673db9ad5103.zip
git-4a6067cda51b592871144eb050d4673db9ad5103.tar.gz
git-4a6067cda51b592871144eb050d4673db9ad5103.tar.bz2
refs.c: migrate internal ref iteration to pass thru repository argument
In 60ce76d3581 (refs: add repository argument to for_each_replace_ref, 2018-04-11) and 0d296c57aec (refs: allow for_each_replace_ref to handle arbitrary repositories, 2018-04-11), for_each_replace_ref learned how to iterate over refs by a given arbitrary repository. New attempts in the object store conversion have shown that it is useful to have the repository handle available that the refs iteration is currently iterating over. To achieve this goal we will need to add a repository argument to each_ref_fn in refs.h. However as many callers rely on the signature such a patch would be too large. So convert the internals of the ref subsystem first to pass through a repository argument without exposing the change to the user. Assume the_repository for the passed through repository, although it is not used anywhere yet. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r--refs/iterator.c6
-rw-r--r--refs/refs-internal.h5
2 files changed, 6 insertions, 5 deletions
diff --git a/refs/iterator.c b/refs/iterator.c
index 2ac91ac..629e00a 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -407,15 +407,15 @@ struct ref_iterator *prefix_ref_iterator_begin(struct ref_iterator *iter0,
struct ref_iterator *current_ref_iter = NULL;
-int do_for_each_ref_iterator(struct ref_iterator *iter,
- each_ref_fn fn, void *cb_data)
+int do_for_each_repo_ref_iterator(struct repository *r, struct ref_iterator *iter,
+ each_repo_ref_fn fn, void *cb_data)
{
int retval = 0, ok;
struct ref_iterator *old_ref_iter = current_ref_iter;
current_ref_iter = iter;
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
- retval = fn(iter->refname, iter->oid, iter->flags, cb_data);
+ retval = fn(r, iter->refname, iter->oid, iter->flags, cb_data);
if (retval) {
/*
* If ref_iterator_abort() returns ITER_ERROR,
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 04425d6..89d7dd4 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -474,8 +474,9 @@ extern struct ref_iterator *current_ref_iter;
* adapter between the callback style of reference iteration and the
* iterator style.
*/
-int do_for_each_ref_iterator(struct ref_iterator *iter,
- each_ref_fn fn, void *cb_data);
+int do_for_each_repo_ref_iterator(struct repository *r,
+ struct ref_iterator *iter,
+ each_repo_ref_fn fn, void *cb_data);
/*
* Only include per-worktree refs in a do_for_each_ref*() iteration.