2039
strbuf_release(&prefix);
2040
}
2041
2042
-int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store,
2043
- const char *namespace,
2044
- const char **patterns,
2045
- const char **exclude_patterns,
2046
- refs_for_each_cb fn, void *cb_data)
2042
+int refs_for_each_ref_in_prefixes(struct ref_store *ref_store,
2043
+ const char **prefixes,
2044
+ const struct refs_for_each_ref_options *opts,
2045
+ refs_for_each_cb cb, void *cb_data)
2046
{
2048
- struct strvec namespaced_exclude_patterns = STRVEC_INIT;
2049
- struct string_list prefixes = STRING_LIST_INIT_DUP;
2047
+ struct string_list longest_prefixes = STRING_LIST_INIT_DUP;
2048
struct string_list_item *prefix;
2051
- struct strbuf buf = STRBUF_INIT;
2052
- int ret = 0, namespace_len;
2049
+ int ret = 0;
2050
2054
- find_longest_prefixes(&prefixes, patterns);
2051
+ if (opts->prefix)
2052
+ BUG("refs_for_each_ref_in_prefixes called with specific prefix");
2053
2056
- if (namespace)
2057
- strbuf_addstr(&buf, namespace);
2058
- namespace_len = buf.len;
2054
+ find_longest_prefixes(&longest_prefixes, prefixes);
2055
2060
- exclude_patterns = get_namespaced_exclude_patterns(exclude_patterns,
2061
- namespace,
2062
- &namespaced_exclude_patterns);
2056
+ for_each_string_list_item(prefix, &longest_prefixes) {
2057
+ struct refs_for_each_ref_options prefix_opts = *opts;
2058
+ prefix_opts.prefix = prefix->string;
2059
2064
- for_each_string_list_item(prefix, &prefixes) {
2065
- strbuf_addstr(&buf, prefix->string);
2066
- ret = refs_for_each_fullref_in(ref_store, buf.buf,
2067
- exclude_patterns, fn, cb_data);
2060
+ ret = refs_for_each_ref_ext(ref_store, cb, cb_data,
2061
+ &prefix_opts);
2062
if (ret)
2063
break;
2070
- strbuf_setlen(&buf, namespace_len);
2064
}
2065
2073
- strvec_clear(&namespaced_exclude_patterns);
2074
- string_list_clear(&prefixes, 0);
2075
- strbuf_release(&buf);
2066
+ string_list_clear(&longest_prefixes, 0);
2067
return ret;
2068
}
2069