refs: replace `refs_for_each_ref_in()`
Replace calls to `refs_for_each_ref_in()` 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>main
parent
5507200b50
commit
00be226f1f
8
bisect.c
8
bisect.c
|
|
@ -473,8 +473,12 @@ static int register_ref(const struct reference *ref, void *cb_data UNUSED)
|
|||
|
||||
static int read_bisect_refs(void)
|
||||
{
|
||||
return refs_for_each_ref_in(get_main_ref_store(the_repository),
|
||||
"refs/bisect/", register_ref, NULL);
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = "refs/bisect/",
|
||||
.trim_prefix = strlen("refs/bisect/"),
|
||||
};
|
||||
return refs_for_each_ref_ext(get_main_ref_store(the_repository),
|
||||
register_ref, NULL, &opts);
|
||||
}
|
||||
|
||||
static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
|
||||
|
|
|
|||
|
|
@ -613,13 +613,18 @@ static int opt_with_value(const char *arg, const char *opt, const char **value)
|
|||
|
||||
static void handle_ref_opt(const char *pattern, const char *prefix)
|
||||
{
|
||||
if (pattern)
|
||||
if (pattern) {
|
||||
refs_for_each_glob_ref_in(get_main_ref_store(the_repository),
|
||||
show_reference, pattern, prefix,
|
||||
NULL);
|
||||
else
|
||||
refs_for_each_ref_in(get_main_ref_store(the_repository),
|
||||
prefix, show_reference, NULL);
|
||||
} else {
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = prefix,
|
||||
.trim_prefix = strlen(prefix),
|
||||
};
|
||||
refs_for_each_ref_ext(get_main_ref_store(the_repository),
|
||||
show_reference, NULL, &opts);
|
||||
}
|
||||
clear_ref_exclusions(&ref_excludes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3326,6 +3326,7 @@ static const struct string_list *bitmap_preferred_tips(struct repository *r)
|
|||
void for_each_preferred_bitmap_tip(struct repository *repo,
|
||||
refs_for_each_cb cb, void *cb_data)
|
||||
{
|
||||
struct refs_for_each_ref_options opts = { 0 };
|
||||
struct string_list_item *item;
|
||||
const struct string_list *preferred_tips;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
|
@ -3335,16 +3336,16 @@ void for_each_preferred_bitmap_tip(struct repository *repo,
|
|||
return;
|
||||
|
||||
for_each_string_list_item(item, preferred_tips) {
|
||||
const char *pattern = item->string;
|
||||
opts.prefix = item->string;
|
||||
|
||||
if (!ends_with(pattern, "/")) {
|
||||
if (!ends_with(opts.prefix, "/")) {
|
||||
strbuf_reset(&buf);
|
||||
strbuf_addf(&buf, "%s/", pattern);
|
||||
pattern = buf.buf;
|
||||
strbuf_addf(&buf, "%s/", opts.prefix);
|
||||
opts.prefix = buf.buf;
|
||||
}
|
||||
|
||||
refs_for_each_ref_in(get_main_ref_store(repo),
|
||||
pattern, cb, cb_data);
|
||||
refs_for_each_ref_ext(get_main_ref_store(repo),
|
||||
cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
strbuf_release(&buf);
|
||||
|
|
|
|||
34
refs.c
34
refs.c
|
|
@ -529,19 +529,31 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
|
|||
refs_for_each_rawref(refs, warn_if_dangling_symref, &data);
|
||||
}
|
||||
|
||||
int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
|
||||
int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
|
||||
{
|
||||
return refs_for_each_ref_in(refs, "refs/tags/", fn, cb_data);
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = "refs/tags/",
|
||||
.trim_prefix = strlen("refs/tags/"),
|
||||
};
|
||||
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
int refs_for_each_branch_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
|
||||
int refs_for_each_branch_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
|
||||
{
|
||||
return refs_for_each_ref_in(refs, "refs/heads/", fn, cb_data);
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = "refs/heads/",
|
||||
.trim_prefix = strlen("refs/heads/"),
|
||||
};
|
||||
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
int refs_for_each_remote_ref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
|
||||
int refs_for_each_remote_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
|
||||
{
|
||||
return refs_for_each_ref_in(refs, "refs/remotes/", fn, cb_data);
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = "refs/remotes/",
|
||||
.trim_prefix = strlen("refs/remotes/"),
|
||||
};
|
||||
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
int refs_head_ref_namespaced(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
|
||||
|
|
@ -1934,16 +1946,6 @@ int refs_for_each_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data
|
|||
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
|
||||
refs_for_each_cb cb, void *cb_data)
|
||||
{
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = prefix,
|
||||
.trim_prefix = strlen(prefix),
|
||||
};
|
||||
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
|
||||
}
|
||||
|
||||
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
|
||||
const char **exclude_patterns,
|
||||
refs_for_each_cb cb, void *cb_data)
|
||||
|
|
|
|||
2
refs.h
2
refs.h
|
|
@ -501,8 +501,6 @@ int refs_for_each_ref(struct ref_store *refs,
|
|||
int refs_for_each_ref_ext(struct ref_store *refs,
|
||||
refs_for_each_cb cb, void *cb_data,
|
||||
const struct refs_for_each_ref_options *opts);
|
||||
int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
|
||||
refs_for_each_cb fn, void *cb_data);
|
||||
int refs_for_each_tag_ref(struct ref_store *refs,
|
||||
refs_for_each_cb fn, void *cb_data);
|
||||
int refs_for_each_branch_ref(struct ref_store *refs,
|
||||
|
|
|
|||
|
|
@ -163,8 +163,11 @@ static int each_ref(const struct reference *ref, void *cb_data UNUSED)
|
|||
static int cmd_for_each_ref(struct ref_store *refs, const char **argv)
|
||||
{
|
||||
const char *prefix = notnull(*argv++, "prefix");
|
||||
|
||||
return refs_for_each_ref_in(refs, prefix, each_ref, NULL);
|
||||
struct refs_for_each_ref_options opts = {
|
||||
.prefix = prefix,
|
||||
.trim_prefix = strlen(prefix),
|
||||
};
|
||||
return refs_for_each_ref_ext(refs, each_ref, NULL, &opts);
|
||||
}
|
||||
|
||||
static int cmd_for_each_ref__exclude(struct ref_store *refs, const char **argv)
|
||||
|
|
|
|||
Loading…
Reference in New Issue