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")
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);
}
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;
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);
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)
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)
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,
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)