1848
refs_for_each_cb cb, void *cb_data,
1849
const struct refs_for_each_ref_options *opts)
1850
{
1851
+ struct strvec namespaced_exclude_patterns = STRVEC_INIT;
1852
+ struct strbuf namespaced_prefix = STRBUF_INIT;
1853
struct strbuf real_pattern = STRBUF_INIT;
1854
struct for_each_ref_filter filter;
1855
struct ref_iterator *iter;
1856
size_t trim_prefix = opts->trim_prefix;
1857
+ const char **exclude_patterns;
1858
+ const char *prefix;
1859
int ret;
1860
1861
if (!refs)
1890
cb_data = &filter;
1891
}
1892
1889
- iter = refs_ref_iterator_begin(refs, opts->prefix ? opts->prefix : "",
1890
- opts->exclude_patterns,
1893
+ if (opts->namespace) {
1894
+ strbuf_addstr(&namespaced_prefix, opts->namespace);
1895
+ if (opts->prefix)
1896
+ strbuf_addstr(&namespaced_prefix, opts->prefix);
1897
+ else
1898
+ strbuf_addstr(&namespaced_prefix, "refs/");
1899
+
1900
+ prefix = namespaced_prefix.buf;
1901
+ exclude_patterns = get_namespaced_exclude_patterns(opts->exclude_patterns,
1902
+ opts->namespace,
1903
+ &namespaced_exclude_patterns);
1904
+ } else {
1905
+ prefix = opts->prefix ? opts->prefix : "";
1906
+ exclude_patterns = opts->exclude_patterns;
1907
+ }
1908
+
1909
+ iter = refs_ref_iterator_begin(refs, prefix, exclude_patterns,
1910
trim_prefix, opts->flags);
1911
1912
ret = do_for_each_ref_iterator(iter, cb, cb_data);
1913
+
1914
+ strvec_clear(&namespaced_exclude_patterns);
1915
+ strbuf_release(&namespaced_prefix);
1916
strbuf_release(&real_pattern);
1917
return ret;
1918
}
1959
const char **exclude_patterns,
1960
refs_for_each_cb cb, void *cb_data)
1961
{
1940
- struct refs_for_each_ref_options opts = { 0 };
1941
- struct strvec namespaced_exclude_patterns = STRVEC_INIT;
1942
- struct strbuf prefix = STRBUF_INIT;
1943
- int ret;
1944
-
1945
- opts.exclude_patterns = get_namespaced_exclude_patterns(exclude_patterns,
1946
- get_git_namespace(),
1947
- &namespaced_exclude_patterns);
1948
- strbuf_addf(&prefix, "%srefs/", get_git_namespace());
1949
- opts.prefix = prefix.buf;
1950
-
1951
- ret = refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1952
-
1953
- strvec_clear(&namespaced_exclude_patterns);
1954
- strbuf_release(&prefix);
1955
- return ret;
1962
+ struct refs_for_each_ref_options opts = {
1963
+ .exclude_patterns = exclude_patterns,
1964
+ .namespace = get_git_namespace(),
1965
+ };
1966
+ return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1967
}
1968
1969
int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)