Skip to content

Commit 3fc1ad0

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 4091d29 commit 3fc1ad0

5 files changed

Lines changed: 15 additions & 19 deletions

File tree

builtin/fetch.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,9 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
15421542

15431543
for (i = 0; i < negotiation_tip.nr; i++) {
15441544
const char *s = negotiation_tip.items[i].string;
1545+
struct refs_for_each_ref_options opts = {
1546+
.pattern = s,
1547+
};
15451548
int old_nr;
15461549
if (!has_glob_specials(s)) {
15471550
struct object_id oid;
@@ -1553,8 +1556,8 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
15531556
continue;
15541557
}
15551558
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);
15581561
if (old_nr == oids->nr)
15591562
warning("ignoring --negotiation-tip=%s because it does not match any refs",
15601563
s);

notes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,11 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
952952
{
953953
assert(list->strdup_strings);
954954
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);
957960
} else {
958961
struct object_id oid;
959962
if (repo_get_oid(the_repository, glob, &oid))

refs.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,6 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix,
607607
strbuf_release(&normalized_pattern);
608608
}
609609

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-
619610
const char *prettify_refname(const char *name)
620611
{
621612
if (skip_prefix(name, "refs/heads/", &name) ||

refs.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,6 @@ int refs_for_each_ref_in_prefixes(struct ref_store *refs,
527527
const struct refs_for_each_ref_options *opts,
528528
refs_for_each_cb cb, void *cb_data);
529529

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-
534530
/*
535531
* references matching any pattern in "exclude_patterns" are omitted from the
536532
* result set on a best-effort basis.

revision.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,10 +2814,13 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
28142814
handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
28152815
clear_ref_exclusions(&revs->ref_excludes);
28162816
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
2817+
struct refs_for_each_ref_options opts = {
2818+
.pattern = optarg,
2819+
};
28172820
struct all_refs_cb cb;
28182821
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);
28212824
clear_ref_exclusions(&revs->ref_excludes);
28222825
return argcount;
28232826
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {

0 commit comments

Comments
 (0)