mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
packfile: split up responsibilities of reprepare_packed_git()
In `reprepare_packed_git()` we perform a couple of operations: - We reload alternate object directories. - We clear the loose object cache. - We reprepare packfiles. While the logic is hosted in "packfile.c", it clearly reaches into other subsystems that aren't related to packfiles. Split up the responsibility and introduce `odb_reprepare()` which now becomes responsible for repreparing the whole object database. The existing `reprepare_packed_git()` function is refactored accordingly and only cares about reloading the packfile store now. 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
c36ecc0685
commit
78237ea53d
26
packfile.c
26
packfile.c
@@ -1002,28 +1002,10 @@ static void packfile_store_prepare(struct packfile_store *store)
|
||||
store->initialized = true;
|
||||
}
|
||||
|
||||
void reprepare_packed_git(struct repository *r)
|
||||
void packfile_store_reprepare(struct packfile_store *store)
|
||||
{
|
||||
struct odb_source *source;
|
||||
|
||||
obj_read_lock();
|
||||
|
||||
/*
|
||||
* Reprepare alt odbs, in case the alternates file was modified
|
||||
* during the course of this process. This only _adds_ odbs to
|
||||
* the linked list, so existing odbs will continue to exist for
|
||||
* the lifetime of the process.
|
||||
*/
|
||||
r->objects->loaded_alternates = 0;
|
||||
odb_prepare_alternates(r->objects);
|
||||
|
||||
for (source = r->objects->sources; source; source = source->next)
|
||||
odb_clear_loose_cache(source);
|
||||
|
||||
r->objects->approximate_object_count_valid = 0;
|
||||
r->objects->packfiles->initialized = false;
|
||||
packfile_store_prepare(r->objects->packfiles);
|
||||
obj_read_unlock();
|
||||
store->initialized = false;
|
||||
packfile_store_prepare(store);
|
||||
}
|
||||
|
||||
struct packed_git *get_packed_git(struct repository *r)
|
||||
@@ -1144,7 +1126,7 @@ unsigned long get_size_from_delta(struct packed_git *p,
|
||||
*
|
||||
* Other worrying sections could be the call to close_pack_fd(),
|
||||
* which can close packs even with in-use windows, and to
|
||||
* reprepare_packed_git(). Regarding the former, mmap doc says:
|
||||
* odb_reprepare(). Regarding the former, mmap doc says:
|
||||
* "closing the file descriptor does not unmap the region". And
|
||||
* for the latter, it won't re-open already available packs.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user