2164
return 0;
2165
}
2166
2167
-static void maybe_invalidate_kept_pack_cache(struct repository *r,
2167
+static void maybe_invalidate_kept_pack_cache(struct packfile_store *store,
2168
unsigned flags)
2169
{
2170
- if (!r->objects->packfiles->kept_cache.packs)
2170
+ if (!store->kept_cache.packs)
2171
return;
2172
- if (r->objects->packfiles->kept_cache.flags == flags)
2172
+ if (store->kept_cache.flags == flags)
2173
return;
2174
- FREE_AND_NULL(r->objects->packfiles->kept_cache.packs);
2175
- r->objects->packfiles->kept_cache.flags = 0;
2174
+ FREE_AND_NULL(store->kept_cache.packs);
2175
+ store->kept_cache.flags = 0;
2176
}
2177
2178
-struct packed_git **kept_pack_cache(struct repository *r, unsigned flags)
2178
+struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *store,
2179
+ unsigned flags)
2180
{
2180
- maybe_invalidate_kept_pack_cache(r, flags);
2181
+ maybe_invalidate_kept_pack_cache(store, flags);
2182
2182
- if (!r->objects->packfiles->kept_cache.packs) {
2183
+ if (!store->kept_cache.packs) {
2184
struct packed_git **packs = NULL;
2185
+ struct packfile_list_entry *e;
2186
size_t nr = 0, alloc = 0;
2185
- struct packed_git *p;
2187
2188
/*
2189
* We want "all" packs here, because we need to cover ones that
2193
* covers, one kept and one not kept, but the midx returns only
2194
* the non-kept version.
2195
*/
2195
- repo_for_each_pack(r, p) {
2196
- if ((p->pack_keep && (flags & ON_DISK_KEEP_PACKS)) ||
2197
- (p->pack_keep_in_core && (flags & IN_CORE_KEEP_PACKS))) {
2196
+ for (e = packfile_store_get_packs(store); e; e = e->next) {
2197
+ struct packed_git *p = e->pack;
2198
+
2199
+ if ((p->pack_keep && (flags & KEPT_PACK_ON_DISK)) ||
2200
+ (p->pack_keep_in_core && (flags & KEPT_PACK_IN_CORE))) {
2201
ALLOC_GROW(packs, nr + 1, alloc);
2202
packs[nr++] = p;
2203
}
2205
ALLOC_GROW(packs, nr + 1, alloc);
2206
packs[nr] = NULL;
2207
2205
- r->objects->packfiles->kept_cache.packs = packs;
2206
- r->objects->packfiles->kept_cache.flags = flags;
2208
+ store->kept_cache.packs = packs;
2209
+ store->kept_cache.flags = flags;
2210
}
2211
2209
- return r->objects->packfiles->kept_cache.packs;
2212
+ return store->kept_cache.packs;
2213
}
2214
2215
int find_kept_pack_entry(struct repository *r,
2217
unsigned flags,
2218
struct pack_entry *e)
2219
{
2217
- struct packed_git **cache;
2220
+ struct packed_git **cache = packfile_store_get_kept_pack_cache(r->objects->packfiles, flags);
2221
2219
- for (cache = kept_pack_cache(r, flags); *cache; cache++) {
2222
+ for (; *cache; cache++) {
2223
struct packed_git *p = *cache;
2224
if (fill_pack_entry(oid, e, p))
2225
return 1;