223
224
odb_prepare_alternates(r->objects);
225
for (source = r->objects->sources; source; source = source->next) {
226
- if (oidtree_contains(odb_loose_cache(source, oid), oid))
226
+ if (oidtree_contains(odb_source_loose_cache(source, oid), oid))
227
return 1;
228
}
229
return 0;
1802
return 0;
1803
}
1804
1805
-struct oidtree *odb_loose_cache(struct odb_source *source,
1806
- const struct object_id *oid)
1805
+struct oidtree *odb_source_loose_cache(struct odb_source *source,
1806
+ const struct object_id *oid)
1807
{
1808
int subdir_nr = oid->hash[0];
1809
struct strbuf buf = STRBUF_INIT;
1810
- size_t word_bits = bitsizeof(source->loose_objects_subdir_seen[0]);
1810
+ size_t word_bits = bitsizeof(source->loose->subdir_seen[0]);
1811
size_t word_index = subdir_nr / word_bits;
1812
size_t mask = (size_t)1u << (subdir_nr % word_bits);
1813
uint32_t *bitmap;
1814
1815
if (subdir_nr < 0 ||
1816
- (size_t) subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))
1816
+ (size_t) subdir_nr >= bitsizeof(source->loose->subdir_seen))
1817
BUG("subdir_nr out of range");
1818
1819
- bitmap = &source->loose_objects_subdir_seen[word_index];
1819
+ bitmap = &source->loose->subdir_seen[word_index];
1820
if (*bitmap & mask)
1821
- return source->loose_objects_cache;
1822
- if (!source->loose_objects_cache) {
1823
- ALLOC_ARRAY(source->loose_objects_cache, 1);
1824
- oidtree_init(source->loose_objects_cache);
1821
+ return source->loose->cache;
1822
+ if (!source->loose->cache) {
1823
+ ALLOC_ARRAY(source->loose->cache, 1);
1824
+ oidtree_init(source->loose->cache);
1825
}
1826
strbuf_addstr(&buf, source->path);
1827
for_each_file_in_obj_subdir(subdir_nr, &buf,
1828
source->odb->repo->hash_algo,
1829
append_loose_object,
1830
NULL, NULL,
1831
- source->loose_objects_cache);
1831
+ source->loose->cache);
1832
*bitmap |= mask;
1833
strbuf_release(&buf);
1834
- return source->loose_objects_cache;
1834
+ return source->loose->cache;
1835
}
1836
1837
void odb_clear_loose_cache(struct odb_source *source)
1838
{
1839
- oidtree_clear(source->loose_objects_cache);
1840
- FREE_AND_NULL(source->loose_objects_cache);
1841
- memset(&source->loose_objects_subdir_seen, 0,
1842
- sizeof(source->loose_objects_subdir_seen));
1839
+ oidtree_clear(source->loose->cache);
1840
+ FREE_AND_NULL(source->loose->cache);
1841
+ memset(&source->loose->subdir_seen, 0,
1842
+ sizeof(source->loose->subdir_seen));
1843
}
1844
1845
static int check_stream_oid(git_zstream *stream,
2006
2007
void odb_source_loose_free(struct odb_source_loose *loose)
2008
{
2009
+ if (!loose)
2010
+ return;
2011
+ odb_clear_loose_cache(loose->source);
2012
free(loose);
2013
}