| 2232 | } |
| 2233 | |
| 2234 | struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *store, |
| 2235 | unsigned flags) |
| 2236 | { |
| 2237 | maybe_invalidate_kept_pack_cache(store, flags); |
| 2238 | |
| 2239 | if (!store->kept_cache.packs) { |
| 2240 | struct packed_git **packs = NULL; |
| 2241 | struct packfile_list_entry *e; |
| 2242 | size_t nr = 0, alloc = 0; |
| 2243 | |
| 2244 | /* |
| 2245 | * We want "all" packs here, because we need to cover ones that |
| 2246 | * are used by a midx, as well. We need to look in every one of |
| 2247 | * them (instead of the midx itself) to cover duplicates. It's |
| 2248 | * possible that an object is found in two packs that the midx |
| 2249 | * covers, one kept and one not kept, but the midx returns only |
| 2250 | * the non-kept version. |
| 2251 | */ |
| 2252 | for (e = packfile_store_get_packs(store); e; e = e->next) { |
| 2253 | struct packed_git *p = e->pack; |
| 2254 | |
| 2255 | if ((p->pack_keep && (flags & KEPT_PACK_ON_DISK)) || |
| 2256 | (p->pack_keep_in_core && (flags & KEPT_PACK_IN_CORE)) || |
| 2257 | (p->pack_keep_in_core_open && (flags & KEPT_PACK_IN_CORE_OPEN))) { |
| 2258 | ALLOC_GROW(packs, nr + 1, alloc); |
| 2259 | packs[nr++] = p; |
| 2260 | } |
| 2261 | } |
| 2262 | ALLOC_GROW(packs, nr + 1, alloc); |
| 2263 | packs[nr] = NULL; |
| 2264 | |
| 2265 | store->kept_cache.packs = packs; |
| 2266 | store->kept_cache.flags = flags; |
| 2267 | } |
| 2268 | |
| 2269 | return store->kept_cache.packs; |
| 2270 | } |
| 2271 | |
| 2272 | int has_object_pack(struct repository *r, const struct object_id *oid) |
| 2273 | { |
no test coverage detected