aboutsummaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/packfile.c b/packfile.c
index 4a6d4a80ea..215a23e42b 100644
--- a/packfile.c
+++ b/packfile.c
@@ -362,9 +362,11 @@ static int unuse_one_window(struct object_database *odb)
struct packed_git *lru_p = NULL;
struct pack_window *lru_w = NULL, *lru_l = NULL;
- for (source = odb->sources; source; source = source->next)
- for (e = source->packfiles->packs.head; e; e = e->next)
+ for (source = odb->sources; source; source = source->next) {
+ struct odb_source_files *files = odb_source_files_downcast(source);
+ for (e = files->packed->packs.head; e; e = e->next)
scan_windows(e->pack, &lru_p, &lru_w, &lru_l);
+ }
if (lru_p) {
munmap(lru_w->base, lru_w->len);
@@ -537,7 +539,8 @@ static int close_one_pack(struct repository *r)
int accept_windows_inuse = 1;
for (source = r->objects->sources; source; source = source->next) {
- for (e = source->packfiles->packs.head; e; e = e->next) {
+ struct odb_source_files *files = odb_source_files_downcast(source);
+ for (e = files->packed->packs.head; e; e = e->next) {
if (e->pack->pack_fd == -1)
continue;
find_lru_pack(e->pack, &lru_p, &mru_w, &accept_windows_inuse);
@@ -987,13 +990,14 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
const char *file_name, void *_data)
{
struct prepare_pack_data *data = (struct prepare_pack_data *)_data;
+ struct odb_source_files *files = odb_source_files_downcast(data->source);
size_t base_len = full_name_len;
if (strip_suffix_mem(full_name, &base_len, ".idx") &&
- !(data->source->packfiles->midx &&
- midx_contains_pack(data->source->packfiles->midx, file_name))) {
+ !(files->packed->midx &&
+ midx_contains_pack(files->packed->midx, file_name))) {
char *trimmed_path = xstrndup(full_name, full_name_len);
- packfile_store_load_pack(data->source->packfiles,
+ packfile_store_load_pack(files->packed,
trimmed_path, data->source->local);
free(trimmed_path);
}
@@ -1247,8 +1251,10 @@ const struct packed_git *has_packed_and_bad(struct repository *r,
struct odb_source *source;
for (source = r->objects->sources; source; source = source->next) {
+ struct odb_source_files *files = odb_source_files_downcast(source);
struct packfile_list_entry *e;
- for (e = source->packfiles->packs.head; e; e = e->next)
+
+ for (e = files->packed->packs.head; e; e = e->next)
if (oidset_contains(&e->pack->bad_objects, oid))
return e->pack;
}
@@ -2175,11 +2181,19 @@ int packfile_store_freshen_object(struct packfile_store *store,
int packfile_store_read_object_info(struct packfile_store *store,
const struct object_id *oid,
struct object_info *oi,
- enum object_info_flags flags UNUSED)
+ enum object_info_flags flags)
{
struct pack_entry e;
int ret;
+ /*
+ * In case the first read didn't surface the object, we have to reload
+ * packfiles. This may cause us to discover new packfiles that have
+ * been added since the last time we have prepared the packfile store.
+ */
+ if (flags & OBJECT_INFO_SECOND_READ)
+ packfile_store_reprepare(store);
+
if (!find_pack_entry(store, oid, &e))
return 1;
@@ -2254,7 +2268,8 @@ int has_object_pack(struct repository *r, const struct object_id *oid)
odb_prepare_alternates(r->objects);
for (source = r->objects->sources; source; source = source->next) {
- int ret = find_pack_entry(source->packfiles, oid, &e);
+ struct odb_source_files *files = odb_source_files_downcast(source);
+ int ret = find_pack_entry(files->packed, oid, &e);
if (ret)
return ret;
}
@@ -2269,9 +2284,10 @@ int has_object_kept_pack(struct repository *r, const struct object_id *oid,
struct pack_entry e;
for (source = r->objects->sources; source; source = source->next) {
+ struct odb_source_files *files = odb_source_files_downcast(source);
struct packed_git **cache;
- cache = packfile_store_get_kept_pack_cache(source->packfiles, flags);
+ cache = packfile_store_get_kept_pack_cache(files->packed, flags);
for (; *cache; cache++) {
struct packed_git *p = *cache;