MCPcopy Create free account
hub / github.com/git/git / packed_ref_iterator_advance

Function packed_ref_iterator_advance

refs/packed-backend.c:980–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980static int packed_ref_iterator_advance(struct ref_iterator *ref_iterator)
981{
982 struct packed_ref_iterator *iter =
983 (struct packed_ref_iterator *)ref_iterator;
984 int ok;
985
986 while ((ok = next_record(iter)) == ITER_OK) {
987 const char *refname = iter->base.ref.name;
988 const char *prefix = iter->prefix;
989
990 if (iter->flags & REFS_FOR_EACH_PER_WORKTREE_ONLY &&
991 !is_per_worktree_ref(iter->base.ref.name))
992 continue;
993
994 if (!(iter->flags & REFS_FOR_EACH_INCLUDE_BROKEN) &&
995 !ref_resolves_to_object(iter->base.ref.name, iter->repo,
996 &iter->oid, iter->flags))
997 continue;
998
999 while (prefix && *prefix) {
1000 if ((unsigned char)*refname < (unsigned char)*prefix)
1001 BUG("packed-refs backend yielded reference preceding its prefix");
1002 else if ((unsigned char)*refname > (unsigned char)*prefix)
1003 return ITER_DONE;
1004 prefix++;
1005 refname++;
1006 }
1007
1008 return ITER_OK;
1009 }
1010
1011 return ok;
1012}
1013
1014static int packed_ref_iterator_seek(struct ref_iterator *ref_iterator,
1015 const char *refname, unsigned int flags)

Callers

nothing calls this directly

Calls 3

next_recordFunction · 0.85
is_per_worktree_refFunction · 0.85
ref_resolves_to_objectFunction · 0.85

Tested by

no test coverage detected