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:
Patrick Steinhardt
2025-09-23 12:17:01 +02:00
committed by Junio C Hamano
parent b7983adb51
commit 535b7a667a
4 changed files with 41 additions and 29 deletions

12
odb.c
View File

@@ -1038,16 +1038,8 @@ void odb_clear(struct object_database *o)
INIT_LIST_HEAD(&o->packed_git_mru);
close_object_store(o);
/*
* `close_object_store()` only closes the packfiles, but doesn't free
* them. We thus have to do this manually.
*/
for (struct packed_git *p = o->packed_git, *next; p; p = next) {
next = p->next;
free(p);
}
o->packed_git = NULL;
packfile_store_free(o->packfiles);
o->packfiles = NULL;
hashmap_clear(&o->pack_map);
string_list_clear(&o->submodule_source_paths, 0);