Merge branch 'kn/for-all-refs'

"git for-each-ref" learned "--include-root-refs" option to show
even the stuff outside the 'refs/' hierarchy.

* kn/for-all-refs:
  for-each-ref: add new option to include root refs
  ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'
  refs: introduce `refs_for_each_include_root_refs()`
  refs: extract out `loose_fill_ref_dir_regular_file()`
  refs: introduce `is_pseudoref()` and `is_headref()`
This commit is contained in:
Junio C Hamano
2024-03-05 09:44:44 -08:00
11 changed files with 243 additions and 53 deletions

View File

@ -364,12 +364,15 @@ static int reftable_ref_iterator_advance(struct ref_iterator *ref_iterator)
break;
/*
* The files backend only lists references contained in
* "refs/". We emulate the same behaviour here and thus skip
* all references that don't start with this prefix.
* The files backend only lists references contained in "refs/" unless
* the root refs are to be included. We emulate the same behaviour here.
*/
if (!starts_with(iter->ref.refname, "refs/"))
if (!starts_with(iter->ref.refname, "refs/") &&
!(iter->flags & DO_FOR_EACH_INCLUDE_ROOT_REFS &&
(is_pseudoref(&iter->refs->base, iter->ref.refname) ||
is_headref(&iter->refs->base, iter->ref.refname)))) {
continue;
}
if (iter->prefix &&
strncmp(iter->prefix, iter->ref.refname, strlen(iter->prefix))) {