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

Function prime_cache_tree_rec

cache-tree.c:796–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796static void prime_cache_tree_rec(struct repository *r,
797 struct cache_tree *it,
798 struct tree *tree,
799 struct strbuf *tree_path)
800{
801 struct tree_desc desc;
802 struct name_entry entry;
803 int cnt;
804 size_t base_path_len = tree_path->len;
805
806 oidcpy(&it->oid, &tree->object.oid);
807
808 init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size);
809 cnt = 0;
810 while (tree_entry(&desc, &entry)) {
811 if (!S_ISDIR(entry.mode))
812 cnt++;
813 else {
814 struct cache_tree_sub *sub;
815 struct tree *subtree = lookup_tree(r, &entry.oid);
816
817 if (repo_parse_tree(the_repository, subtree) < 0)
818 exit(128);
819 sub = cache_tree_sub(it, entry.path);
820 sub->cache_tree = cache_tree();
821
822 /*
823 * Recursively-constructed subtree path is only needed when working
824 * in a sparse index (where it's used to determine whether the
825 * subtree is a sparse directory in the index).
826 */
827 if (r->index->sparse_index) {
828 strbuf_setlen(tree_path, base_path_len);
829 strbuf_add(tree_path, entry.path, entry.pathlen);
830 strbuf_addch(tree_path, '/');
831 }
832
833 /*
834 * If a sparse index is in use, the directory being processed may be
835 * sparse. To confirm that, we can check whether an entry with that
836 * exact name exists in the index. If it does, the created subtree
837 * should be sparse. Otherwise, cache tree expansion should continue
838 * as normal.
839 */
840 if (r->index->sparse_index &&
841 index_entry_exists(r->index, tree_path->buf, tree_path->len))
842 prime_cache_tree_sparse_dir(sub->cache_tree, subtree);
843 else
844 prime_cache_tree_rec(r, sub->cache_tree, subtree, tree_path);
845 cnt += sub->cache_tree->entry_count;
846 }
847 }
848
849 it->entry_count = cnt;
850}
851
852void prime_cache_tree(struct repository *r,
853 struct index_state *istate,

Callers 1

prime_cache_treeFunction · 0.85

Calls 12

oidcpyFunction · 0.85
init_tree_descFunction · 0.85
lookup_treeFunction · 0.85
repo_parse_treeFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_addFunction · 0.85
strbuf_addchFunction · 0.85
index_entry_existsFunction · 0.85
tree_entryFunction · 0.70
cache_tree_subFunction · 0.70
cache_treeFunction · 0.70

Tested by

no test coverage detected