1576
return iter;
1577
}
1578
1579
-/*
1580
- * Call fn for each reference in the specified submodule for which the
1581
- * refname begins with prefix. If trim is non-zero, then trim that
1582
- * many characters off the beginning of each refname before passing
1583
- * the refname to fn. flags can be DO_FOR_EACH_INCLUDE_BROKEN to
1584
- * include broken references in the iteration. If fn ever returns a
1585
- * non-zero value, stop the iteration and return that value;
1586
- * otherwise, return 0.
1587
- */
1588
-static int do_for_each_repo_ref(struct repository *r, const char *prefix,
1589
- each_repo_ref_fn fn, int trim, int flags,
1590
- void *cb_data)
1591
-{
1592
- struct ref_iterator *iter;
1593
- struct ref_store *refs = get_main_ref_store(r);
1594
-
1595
- if (!refs)
1596
- return 0;
1597
-
1598
- iter = refs_ref_iterator_begin(refs, prefix, NULL, trim, flags);
1599
-
1600
- return do_for_each_repo_ref_iterator(r, iter, fn, cb_data);
1601
-}
1602
-
1603
-struct do_for_each_ref_help {
1604
- each_ref_fn *fn;
1605
- void *cb_data;
1606
-};
1607
-
1608
-static int do_for_each_ref_helper(struct repository *r UNUSED,
1609
- const char *refname,
1610
- const struct object_id *oid,
1611
- int flags,
1612
- void *cb_data)
1613
-{
1614
- struct do_for_each_ref_help *hp = cb_data;
1615
-
1616
- return hp->fn(refname, oid, flags, hp->cb_data);
1617
-}
1618
-
1579
static int do_for_each_ref(struct ref_store *refs, const char *prefix,
1580
const char **exclude_patterns,
1581
each_ref_fn fn, int trim,
1582
enum do_for_each_ref_flags flags, void *cb_data)
1583
{
1584
struct ref_iterator *iter;
1625
- struct do_for_each_ref_help hp = { fn, cb_data };
1585
1586
if (!refs)
1587
return 0;
1589
iter = refs_ref_iterator_begin(refs, prefix, exclude_patterns, trim,
1590
flags);
1591
1633
- return do_for_each_repo_ref_iterator(the_repository, iter,
1634
- do_for_each_ref_helper, &hp);
1592
+ return do_for_each_ref_iterator(iter, fn, cb_data);
1593
}
1594
1595
int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1610
return do_for_each_ref(refs, prefix, exclude_patterns, fn, 0, 0, cb_data);
1611
}
1612
1655
-int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data)
1613
+int refs_for_each_replace_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
1614
{
1615
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
1658
- return do_for_each_repo_ref(r, git_replace_ref_base, fn,
1659
- strlen(git_replace_ref_base),
1660
- DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1616
+ return do_for_each_ref(refs, git_replace_ref_base, NULL, fn,
1617
+ strlen(git_replace_ref_base),
1618
+ DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
1619
}
1620
1621
int refs_for_each_namespaced_ref(struct ref_store *refs,
2383
void *cb_data;
2384
};
2385
2428
-static int do_for_each_reflog_helper(struct repository *r UNUSED,
2429
- const char *refname,
2386
+static int do_for_each_reflog_helper(const char *refname,
2387
const struct object_id *oid UNUSED,
2388
int flags,
2389
void *cb_data)
2399
2400
iter = refs->be->reflog_iterator_begin(refs);
2401
2445
- return do_for_each_repo_ref_iterator(the_repository, iter,
2446
- do_for_each_reflog_helper, &hp);
2402
+ return do_for_each_ref_iterator(iter, do_for_each_reflog_helper, &hp);
2403
}
2404
2405
int refs_for_each_reflog_ent_reverse(struct ref_store *refs,