summaryrefslogtreecommitdiff
path: root/odb.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-10-16 14:42:27 -0700
committerJunio C Hamano <gitster@pobox.com>2025-10-16 14:42:27 -0700
commit057a94fbbb06c754c84ccc02783c348924d4c428 (patch)
tree88f1831717bc09fa77095592e860d6a18511c4b3 /odb.c
parent821f583da6d30a84249f75f33501504d597bc16b (diff)
parent935ab44a0a4fae54f9cd378ede16f19e563e53d9 (diff)
Merge branch 'tb/incremental-midx-part-3.1' into ps/remove-packfile-store-get-packs
* tb/incremental-midx-part-3.1: (64 commits) builtin/repack.c: clean up unused `#include`s repack: move `write_cruft_pack()` out of the builtin repack: move `write_filtered_pack()` out of the builtin repack: move `pack_kept_objects` to `struct pack_objects_args` repack: move `finish_pack_objects_cmd()` out of the builtin builtin/repack.c: pass `write_pack_opts` to `finish_pack_objects_cmd()` repack: extract `write_pack_opts_is_local()` repack: move `find_pack_prefix()` out of the builtin builtin/repack.c: use `write_pack_opts` within `write_cruft_pack()` builtin/repack.c: introduce `struct write_pack_opts` repack: 'write_midx_included_packs' API from the builtin builtin/repack.c: inline packs within `write_midx_included_packs()` builtin/repack.c: pass `repack_write_midx_opts` to `midx_included_packs` builtin/repack.c: inline `remove_redundant_bitmaps()` builtin/repack.c: reorder `remove_redundant_bitmaps()` repack: keep track of MIDX pack names using existing_packs builtin/repack.c: use a string_list for 'midx_pack_names' builtin/repack.c: extract opts struct for 'write_midx_included_packs()' builtin/repack.c: remove ref snapshotting from builtin repack: remove pack_geometry API from the builtin ...
Diffstat (limited to 'odb.c')
-rw-r--r--odb.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/odb.c b/odb.c
index 75c443fe66..65a6cc67b6 100644
--- a/odb.c
+++ b/odb.c
@@ -694,7 +694,7 @@ static int do_oid_object_info_extended(struct object_database *odb,
/* Not a loose object; someone else may have just packed it. */
if (!(flags & OBJECT_INFO_QUICK)) {
- reprepare_packed_git(odb->repo);
+ odb_reprepare(odb->repo->objects);
if (find_pack_entry(odb->repo, real, &e))
break;
}
@@ -996,8 +996,7 @@ struct object_database *odb_new(struct repository *repo)
memset(o, 0, sizeof(*o));
o->repo = repo;
- INIT_LIST_HEAD(&o->packed_git_mru);
- hashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0);
+ o->packfiles = packfile_store_new(o);
pthread_mutex_init(&o->replace_mutex, NULL);
string_list_init_dup(&o->submodule_source_paths);
return o;
@@ -1035,19 +1034,34 @@ void odb_clear(struct object_database *o)
free((char *) o->cached_objects[i].value.buf);
FREE_AND_NULL(o->cached_objects);
- INIT_LIST_HEAD(&o->packed_git_mru);
close_object_store(o);
+ packfile_store_free(o->packfiles);
+ o->packfiles = NULL;
+
+ string_list_clear(&o->submodule_source_paths, 0);
+}
+
+void odb_reprepare(struct object_database *o)
+{
+ struct odb_source *source;
+
+ obj_read_lock();
/*
- * `close_object_store()` only closes the packfiles, but doesn't free
- * them. We thus have to do this manually.
+ * 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.
*/
- for (struct packed_git *p = o->packed_git, *next; p; p = next) {
- next = p->next;
- free(p);
- }
- o->packed_git = NULL;
+ o->loaded_alternates = 0;
+ odb_prepare_alternates(o);
- hashmap_clear(&o->pack_map);
- string_list_clear(&o->submodule_source_paths, 0);
+ for (source = o->sources; source; source = source->next)
+ odb_clear_loose_cache(source);
+
+ o->approximate_object_count_valid = 0;
+
+ packfile_store_reprepare(o->packfiles);
+
+ obj_read_unlock();
}