MCPcopy Index your code
hub / github.com/git/git / prime_ref_dir

Function prime_ref_dir

refs/ref-cache.c:284–319  ·  view source on GitHub ↗

* Load all of the refs from `dir` (recursively) that could possibly * contain references matching `prefix` into our in-memory cache. If * `prefix` is NULL, prime unconditionally. */

Source from the content-addressed store, hash-verified

282 * `prefix` is NULL, prime unconditionally.
283 */
284static void prime_ref_dir(struct ref_dir *dir, const char *prefix)
285{
286 /*
287 * The hard work of loading loose refs is done by get_ref_dir(), so we
288 * just need to recurse through all of the sub-directories. We do not
289 * even need to care about sorting, as traversal order does not matter
290 * to us.
291 */
292 int i;
293 for (i = 0; i < dir->nr; i++) {
294 struct ref_entry *entry = dir->entries[i];
295 if (!(entry->flag & REF_DIR)) {
296 /* Not a directory; no need to recurse. */
297 } else if (!prefix) {
298 /* Recurse in any case: */
299 prime_ref_dir(get_ref_dir(entry), NULL);
300 } else {
301 switch (overlaps_prefix(entry->name, prefix)) {
302 case PREFIX_CONTAINS_DIR:
303 /*
304 * Recurse, and from here down we
305 * don't have to check the prefix
306 * anymore:
307 */
308 prime_ref_dir(get_ref_dir(entry), NULL);
309 break;
310 case PREFIX_WITHIN_DIR:
311 prime_ref_dir(get_ref_dir(entry), prefix);
312 break;
313 case PREFIX_EXCLUDES_DIR:
314 /* No need to prime this directory. */
315 break;
316 }
317 }
318 }
319}
320
321/*
322 * A level in the reference hierarchy that is currently being iterated

Callers 2

cache_ref_iterator_seekFunction · 0.85

Calls 2

get_ref_dirFunction · 0.85
overlaps_prefixFunction · 0.85

Tested by

no test coverage detected