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

Function odb_source_loose_cache

odb/source-loose.c:25–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25static struct oidtree *odb_source_loose_cache(struct odb_source_loose *loose,
26 const struct object_id *oid)
27{
28 int subdir_nr = oid->hash[0];
29 struct strbuf buf = STRBUF_INIT;
30 size_t word_bits = bitsizeof(loose->subdir_seen[0]);
31 size_t word_index = subdir_nr / word_bits;
32 size_t mask = (size_t)1u << (subdir_nr % word_bits);
33 uint32_t *bitmap;
34
35 if (subdir_nr < 0 ||
36 (size_t) subdir_nr >= bitsizeof(loose->subdir_seen))
37 BUG("subdir_nr out of range");
38
39 bitmap = &loose->subdir_seen[word_index];
40 if (*bitmap & mask)
41 return loose->cache;
42 if (!loose->cache) {
43 ALLOC_ARRAY(loose->cache, 1);
44 oidtree_init(loose->cache);
45 }
46 strbuf_addstr(&buf, loose->base.path);
47 for_each_file_in_obj_subdir(subdir_nr, &buf,
48 loose->base.odb->repo->hash_algo,
49 append_loose_object,
50 NULL, NULL,
51 loose->cache);
52 *bitmap |= mask;
53 strbuf_release(&buf);
54 return loose->cache;
55}
56
57static int quick_has_loose(struct odb_source_loose *loose,
58 const struct object_id *oid)

Callers 2

quick_has_looseFunction · 0.85

Calls 4

oidtree_initFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected