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

Function cache_ref_iterator_set_prefix

refs/ref-cache.c:438–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438static int cache_ref_iterator_set_prefix(struct cache_ref_iterator *iter,
439 const char *prefix)
440{
441 struct cache_ref_iterator_level *level;
442 struct ref_dir *dir;
443
444 dir = get_ref_dir(iter->cache->root);
445 if (prefix && *prefix)
446 dir = find_containing_dir(dir, prefix);
447 if (!dir) {
448 iter->levels_nr = 0;
449 return 0;
450 }
451
452 if (iter->prime_dir)
453 prime_ref_dir(dir, prefix);
454 iter->levels_nr = 1;
455 level = &iter->levels[0];
456 level->index = -1;
457 level->dir = dir;
458
459 if (prefix && *prefix) {
460 free(iter->prefix);
461 iter->prefix = xstrdup(prefix);
462 level->prefix_state = PREFIX_WITHIN_DIR;
463 } else {
464 FREE_AND_NULL(iter->prefix);
465 level->prefix_state = PREFIX_CONTAINS_DIR;
466 }
467
468 return 0;
469}
470
471static int cache_ref_iterator_seek(struct ref_iterator *ref_iterator,
472 const char *refname, unsigned int flags)

Callers 1

cache_ref_iterator_seekFunction · 0.85

Calls 4

get_ref_dirFunction · 0.85
find_containing_dirFunction · 0.85
prime_ref_dirFunction · 0.85
xstrdupFunction · 0.85

Tested by

no test coverage detected