From: Han-Wen Nienhuys <hanwen@xxxxxxxxxx> This changes behavior for in for_each_[raw]ref and for_each_fullref_in_pattern. This happens implicitly in the files/packed ref backend; making it explicit simplifies adding alternate ref storage backends, such as reftable. Signed-off-by: Han-Wen Nienhuys <hanwen@xxxxxxxxxx> --- ref-filter.c | 7 ++++--- refs.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ref-filter.c b/ref-filter.c index f2b078db11..88c82b2cca 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1943,6 +1943,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, { struct string_list prefixes = STRING_LIST_INIT_DUP; struct string_list_item *prefix; + const char *all = "refs/"; int ret; if (!filter->match_as_path) { @@ -1951,7 +1952,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, * prefixes like "refs/heads/" etc. are stripped off, * so we have to look at everything: */ - return for_each_fullref_in("", cb, cb_data, broken); + return for_each_fullref_in(all, cb, cb_data, broken); } if (filter->ignore_case) { @@ -1960,12 +1961,12 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, * so just return everything and let the caller * sort it out. */ - return for_each_fullref_in("", cb, cb_data, broken); + return for_each_fullref_in(all, cb, cb_data, broken); } if (!filter->name_patterns[0]) { /* no patterns; we have to look at everything */ - return for_each_fullref_in("", cb, cb_data, broken); + return for_each_fullref_in(all, cb, cb_data, broken); } find_longest_prefixes(&prefixes, filter->name_patterns); diff --git a/refs.c b/refs.c index 5e65e79f24..d4b5397c8f 100644 --- a/refs.c +++ b/refs.c @@ -1458,7 +1458,7 @@ static int do_for_each_ref(struct ref_store *refs, const char *prefix, int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data) { - return do_for_each_ref(refs, "", fn, 0, 0, cb_data); + return do_for_each_ref(refs, "refs/", fn, 0, 0, cb_data); } int for_each_ref(each_ref_fn fn, void *cb_data) @@ -1518,8 +1518,8 @@ int for_each_namespaced_ref(each_ref_fn fn, void *cb_data) int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data) { - return do_for_each_ref(refs, "", fn, 0, - DO_FOR_EACH_INCLUDE_BROKEN, cb_data); + return do_for_each_ref(refs, "refs/", fn, 0, DO_FOR_EACH_INCLUDE_BROKEN, + cb_data); } int for_each_rawref(each_ref_fn fn, void *cb_data) -- gitgitgadget