357
358
static int unuse_one_window(struct object_database *odb)
359
{
360
+ struct odb_source *source;
361
struct packfile_list_entry *e;
362
struct packed_git *lru_p = NULL;
363
struct pack_window *lru_w = NULL, *lru_l = NULL;
364
364
- for (e = odb->packfiles->packs.head; e; e = e->next)
365
- scan_windows(e->pack, &lru_p, &lru_w, &lru_l);
365
+ for (source = odb->sources; source; source = source->next)
366
+ for (e = source->packfiles->packs.head; e; e = e->next)
367
+ scan_windows(e->pack, &lru_p, &lru_w, &lru_l);
368
369
if (lru_p) {
370
munmap(lru_w->base, lru_w->len);
530
531
static int close_one_pack(struct repository *r)
532
{
533
+ struct odb_source *source;
534
struct packfile_list_entry *e;
535
struct packed_git *lru_p = NULL;
536
struct pack_window *mru_w = NULL;
537
int accept_windows_inuse = 1;
538
536
- for (e = r->objects->packfiles->packs.head; e; e = e->next) {
537
- if (e->pack->pack_fd == -1)
538
- continue;
539
- find_lru_pack(e->pack, &lru_p, &mru_w, &accept_windows_inuse);
539
+ for (source = r->objects->sources; source; source = source->next) {
540
+ for (e = source->packfiles->packs.head; e; e = e->next) {
541
+ if (e->pack->pack_fd == -1)
542
+ continue;
543
+ find_lru_pack(e->pack, &lru_p, &mru_w, &accept_windows_inuse);
544
+ }
545
}
546
547
if (lru_p)
992
if (strip_suffix_mem(full_name, &base_len, ".idx") &&
993
!(data->source->midx && midx_contains_pack(data->source->midx, file_name))) {
994
char *trimmed_path = xstrndup(full_name, full_name_len);
990
- packfile_store_load_pack(data->source->odb->packfiles,
995
+ packfile_store_load_pack(data->source->packfiles,
996
trimmed_path, data->source->local);
997
free(trimmed_path);
998
}
1250
const struct packed_git *has_packed_and_bad(struct repository *r,
1251
const struct object_id *oid)
1252
{
1248
- struct packfile_list_entry *e;
1253
+ struct odb_source *source;
1254
+
1255
+ for (source = r->objects->sources; source; source = source->next) {
1256
+ struct packfile_list_entry *e;
1257
+ for (e = source->packfiles->packs.head; e; e = e->next)
1258
+ if (oidset_contains(&e->pack->bad_objects, oid))
1259
+ return e->pack;
1260
+ }
1261
1250
- for (e = r->objects->packfiles->packs.head; e; e = e->next)
1251
- if (oidset_contains(&e->pack->bad_objects, oid))
1252
- return e->pack;
1262
return NULL;
1263
}
1264
2098
const struct object_id *oid,
2099
struct pack_entry *e)
2100
{
2092
- struct packfile_list_entry *l;
2101
+ struct odb_source *source;
2102
2094
- packfile_store_prepare(r->objects->packfiles);
2103
+ /*
2104
+ * Note: `packfile_store_prepare()` prepares stores from all sources.
2105
+ * This will be fixed in a subsequent commit.
2106
+ */
2107
+ packfile_store_prepare(r->objects->sources->packfiles);
2108
2096
- for (struct odb_source *source = r->objects->sources; source; source = source->next)
2109
+ for (source = r->objects->sources; source; source = source->next)
2110
if (source->midx && fill_midx_entry(source->midx, oid, e))
2111
return 1;
2112
2100
- if (!r->objects->packfiles->packs.head)
2101
- return 0;
2113
+ for (source = r->objects->sources; source; source = source->next) {
2114
+ struct packfile_list_entry *l;
2115
2103
- for (l = r->objects->packfiles->packs.head; l; l = l->next) {
2104
- struct packed_git *p = l->pack;
2116
+ for (l = source->packfiles->packs.head; l; l = l->next) {
2117
+ struct packed_git *p = l->pack;
2118
2106
- if (!p->multi_pack_index && fill_pack_entry(oid, e, p)) {
2107
- if (!r->objects->packfiles->skip_mru_updates)
2108
- packfile_list_prepend(&r->objects->packfiles->packs, p);
2109
- return 1;
2119
+ if (!p->multi_pack_index && fill_pack_entry(oid, e, p)) {
2120
+ if (!source->packfiles->skip_mru_updates)
2121
+ packfile_list_prepend(&source->packfiles->packs, p);
2122
+ return 1;
2123
+ }
2124
}
2125
}
2126
+
2127
return 0;
2128
}
2129
2231
unsigned flags,
2232
struct pack_entry *e)
2233
{
2219
- struct packed_git **cache = packfile_store_get_kept_pack_cache(r->objects->packfiles, flags);
2234
+ struct odb_source *source;
2235
2221
- for (; *cache; cache++) {
2222
- struct packed_git *p = *cache;
2223
- if (fill_pack_entry(oid, e, p))
2224
- return 1;
2236
+ for (source = r->objects->sources; source; source = source->next) {
2237
+ struct packed_git **cache;
2238
+
2239
+ cache = packfile_store_get_kept_pack_cache(source->packfiles, flags);
2240
+
2241
+ for (; *cache; cache++) {
2242
+ struct packed_git *p = *cache;
2243
+ if (fill_pack_entry(oid, e, p))
2244
+ return 1;
2245
+ }
2246
}
2247
2248
return 0;
2308
int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
2309
void *data, enum for_each_object_flags flags)
2310
{
2290
- struct packed_git *p;
2311
+ struct odb_source *source;
2312
int r = 0;
2313
int pack_errors = 0;
2314
2294
- repo->objects->packfiles->skip_mru_updates = true;
2295
- repo_for_each_pack(repo, p) {
2296
- if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
2297
- continue;
2298
- if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
2299
- !p->pack_promisor)
2300
- continue;
2301
- if ((flags & FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
2302
- p->pack_keep_in_core)
2303
- continue;
2304
- if ((flags & FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
2305
- p->pack_keep)
2306
- continue;
2307
- if (open_pack_index(p)) {
2308
- pack_errors = 1;
2309
- continue;
2315
+ odb_prepare_alternates(repo->objects);
2316
+
2317
+ for (source = repo->objects->sources; source; source = source->next) {
2318
+ struct packfile_list_entry *e;
2319
+
2320
+ source->packfiles->skip_mru_updates = true;
2321
+
2322
+ for (e = packfile_store_get_packs(source->packfiles); e; e = e->next) {
2323
+ struct packed_git *p = e->pack;
2324
+
2325
+ if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
2326
+ continue;
2327
+ if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
2328
+ !p->pack_promisor)
2329
+ continue;
2330
+ if ((flags & FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
2331
+ p->pack_keep_in_core)
2332
+ continue;
2333
+ if ((flags & FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
2334
+ p->pack_keep)
2335
+ continue;
2336
+ if (open_pack_index(p)) {
2337
+ pack_errors = 1;
2338
+ continue;
2339
+ }
2340
+
2341
+ r = for_each_object_in_pack(p, cb, data, flags);
2342
+ if (r)
2343
+ break;
2344
}
2311
- r = for_each_object_in_pack(p, cb, data, flags);
2345
+
2346
+ source->packfiles->skip_mru_updates = false;
2347
+
2348
if (r)
2349
break;
2350
}
2315
- repo->objects->packfiles->skip_mru_updates = false;
2351
2352
return r ? r : pack_errors;
2353
}