refs: replace `refs_for_each_glob_ref()`
Replace calls to `refs_for_each_glob_ref()` with the newly introduced `refs_for_each_ref_ext()` function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Feb 23, 2026 at 12:59 UTC
3fc1ad03c6243b44c2dcab480acaced44921b1c5
5 files changed
+15
-19
builtin/fetch.c
+5
-2
@@ -1542,6 +1542,9 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
1542
1543
for (i = 0; i < negotiation_tip.nr; i++) {
1544
const char *s = negotiation_tip.items[i].string;
1545
+ struct refs_for_each_ref_options opts = {
1546
+ .pattern = s,
1547
+ };
1548
int old_nr;
1549
if (!has_glob_specials(s)) {
1550
struct object_id oid;
@@ -1553,8 +1556,8 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
1556
continue;
1557
}
1558
old_nr = oids->nr;
1556
- refs_for_each_glob_ref(get_main_ref_store(the_repository),
1557
- add_oid, s, oids);
1559
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
1560
+ add_oid, oids, &opts);
1561
if (old_nr == oids->nr)
1562
warning("ignoring --negotiation-tip=%s because it does not match any refs",
1563
s);
notes.c
+5
-2
@@ -952,8 +952,11 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
952
{
953
assert(list->strdup_strings);
954
if (has_glob_specials(glob)) {
955
- refs_for_each_glob_ref(get_main_ref_store(the_repository),
956
- string_list_add_one_ref, glob, list);
955
+ struct refs_for_each_ref_options opts = {
956
+ .pattern = glob,
957
+ };
958
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
959
+ string_list_add_one_ref, list, &opts);
960
} else {
961
struct object_id oid;
962
if (repo_get_oid(the_repository, glob, &oid))
refs.c
-9
@@ -607,15 +607,6 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix,
607
strbuf_release(&normalized_pattern);
608
}
609
610
-int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb cb,
611
- const char *pattern, void *cb_data)
612
-{
613
- struct refs_for_each_ref_options opts = {
614
- .pattern = pattern,
615
- };
616
- return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
617
-}
618
-
610
const char *prettify_refname(const char *name)
611
{
612
if (skip_prefix(name, "refs/heads/", &name) ||
refs.h
-4
@@ -527,10 +527,6 @@ int refs_for_each_ref_in_prefixes(struct ref_store *refs,
527
const struct refs_for_each_ref_options *opts,
528
refs_for_each_cb cb, void *cb_data);
529
530
-/* iterates all refs that match the specified glob pattern. */
531
-int refs_for_each_glob_ref(struct ref_store *refs, refs_for_each_cb fn,
532
- const char *pattern, void *cb_data);
533
-
530
/*
531
* references matching any pattern in "exclude_patterns" are omitted from the
532
* result set on a best-effort basis.
revision.c
+5
-2
@@ -2814,10 +2814,13 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
2814
handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
2815
clear_ref_exclusions(&revs->ref_excludes);
2816
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
2817
+ struct refs_for_each_ref_options opts = {
2818
+ .pattern = optarg,
2819
+ };
2820
struct all_refs_cb cb;
2821
init_all_refs_cb(&cb, revs, *flags);
2819
- refs_for_each_glob_ref(get_main_ref_store(the_repository),
2820
- handle_one_ref, optarg, &cb);
2822
+ refs_for_each_ref_ext(get_main_ref_store(the_repository),
2823
+ handle_one_ref, &cb, &opts);
2824
clear_ref_exclusions(&revs->ref_excludes);
2825
return argcount;
2826
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {