mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
odb: move list of packfiles into struct packfile_store
The object database tracks the list of packfiles it currently knows about. With the introduction of the `struct packfile_store` we have a better place to host this list though. Move the list accordingly. Extract the logic from `odb_clear()` that knows to close all such packfiles and move it into the new subsystem, as well. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b7983adb51
commit
535b7a667a
42
packfile.c
42
packfile.c
@@ -278,7 +278,7 @@ static int unuse_one_window(struct packed_git *current)
|
||||
|
||||
if (current)
|
||||
scan_windows(current, &lru_p, &lru_w, &lru_l);
|
||||
for (p = current->repo->objects->packed_git; p; p = p->next)
|
||||
for (p = current->repo->objects->packfiles->packs; p; p = p->next)
|
||||
scan_windows(p, &lru_p, &lru_w, &lru_l);
|
||||
if (lru_p) {
|
||||
munmap(lru_w->base, lru_w->len);
|
||||
@@ -362,13 +362,8 @@ void close_pack(struct packed_git *p)
|
||||
void close_object_store(struct object_database *o)
|
||||
{
|
||||
struct odb_source *source;
|
||||
struct packed_git *p;
|
||||
|
||||
for (p = o->packed_git; p; p = p->next)
|
||||
if (p->do_not_close)
|
||||
BUG("want to close pack marked 'do-not-close'");
|
||||
else
|
||||
close_pack(p);
|
||||
packfile_store_close(o->packfiles);
|
||||
|
||||
for (source = o->sources; source; source = source->next) {
|
||||
if (source->midx)
|
||||
@@ -468,7 +463,7 @@ static int close_one_pack(struct repository *r)
|
||||
struct pack_window *mru_w = NULL;
|
||||
int accept_windows_inuse = 1;
|
||||
|
||||
for (p = r->objects->packed_git; p; p = p->next) {
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next) {
|
||||
if (p->pack_fd == -1)
|
||||
continue;
|
||||
find_lru_pack(p, &lru_p, &mru_w, &accept_windows_inuse);
|
||||
@@ -789,8 +784,8 @@ void install_packed_git(struct repository *r, struct packed_git *pack)
|
||||
if (pack->pack_fd != -1)
|
||||
pack_open_fds++;
|
||||
|
||||
pack->next = r->objects->packed_git;
|
||||
r->objects->packed_git = pack;
|
||||
pack->next = r->objects->packfiles->packs;
|
||||
r->objects->packfiles->packs = pack;
|
||||
|
||||
hashmap_entry_init(&pack->packmap_ent, strhash(pack->pack_name));
|
||||
hashmap_add(&r->objects->pack_map, &pack->packmap_ent);
|
||||
@@ -974,7 +969,7 @@ unsigned long repo_approximate_object_count(struct repository *r)
|
||||
count += m->num_objects;
|
||||
}
|
||||
|
||||
for (p = r->objects->packed_git; p; p = p->next) {
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next) {
|
||||
if (open_pack_index(p))
|
||||
continue;
|
||||
count += p->num_objects;
|
||||
@@ -1015,7 +1010,7 @@ static int sort_pack(const struct packed_git *a, const struct packed_git *b)
|
||||
|
||||
static void rearrange_packed_git(struct repository *r)
|
||||
{
|
||||
sort_packs(&r->objects->packed_git, sort_pack);
|
||||
sort_packs(&r->objects->packfiles->packs, sort_pack);
|
||||
}
|
||||
|
||||
static void prepare_packed_git_mru(struct repository *r)
|
||||
@@ -1024,7 +1019,7 @@ static void prepare_packed_git_mru(struct repository *r)
|
||||
|
||||
INIT_LIST_HEAD(&r->objects->packed_git_mru);
|
||||
|
||||
for (p = r->objects->packed_git; p; p = p->next)
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next)
|
||||
list_add_tail(&p->mru, &r->objects->packed_git_mru);
|
||||
}
|
||||
|
||||
@@ -1073,7 +1068,7 @@ void reprepare_packed_git(struct repository *r)
|
||||
struct packed_git *get_packed_git(struct repository *r)
|
||||
{
|
||||
prepare_packed_git(r);
|
||||
return r->objects->packed_git;
|
||||
return r->objects->packfiles->packs;
|
||||
}
|
||||
|
||||
struct multi_pack_index *get_multi_pack_index(struct odb_source *source)
|
||||
@@ -1094,7 +1089,7 @@ struct packed_git *get_all_packs(struct repository *r)
|
||||
prepare_midx_pack(m, i);
|
||||
}
|
||||
|
||||
return r->objects->packed_git;
|
||||
return r->objects->packfiles->packs;
|
||||
}
|
||||
|
||||
struct list_head *get_packed_git_mru(struct repository *r)
|
||||
@@ -1219,7 +1214,7 @@ const struct packed_git *has_packed_and_bad(struct repository *r,
|
||||
{
|
||||
struct packed_git *p;
|
||||
|
||||
for (p = r->objects->packed_git; p; p = p->next)
|
||||
for (p = r->objects->packfiles->packs; p; p = p->next)
|
||||
if (oidset_contains(&p->bad_objects, oid))
|
||||
return p;
|
||||
return NULL;
|
||||
@@ -2080,7 +2075,7 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
|
||||
if (source->midx && fill_midx_entry(source->midx, oid, e))
|
||||
return 1;
|
||||
|
||||
if (!r->objects->packed_git)
|
||||
if (!r->objects->packfiles->packs)
|
||||
return 0;
|
||||
|
||||
list_for_each(pos, &r->objects->packed_git_mru) {
|
||||
@@ -2343,5 +2338,18 @@ struct packfile_store *packfile_store_new(struct object_database *odb)
|
||||
|
||||
void packfile_store_free(struct packfile_store *store)
|
||||
{
|
||||
for (struct packed_git *p = store->packs, *next; p; p = next) {
|
||||
next = p->next;
|
||||
free(p);
|
||||
}
|
||||
free(store);
|
||||
}
|
||||
|
||||
void packfile_store_close(struct packfile_store *store)
|
||||
{
|
||||
for (struct packed_git *p = store->packs; p; p = p->next) {
|
||||
if (p->do_not_close)
|
||||
BUG("want to close pack marked 'do-not-close'");
|
||||
close_pack(p);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user