aboutsummaryrefslogtreecommitdiff
path: root/odb.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-15 05:50:16 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-15 05:50:16 -0800
commitec16dde5c8c08fe6f26a2183a038e02ea7b2b25f (patch)
treefef31f79ec514c9429614e2518ea48874f2d0801 /odb.c
parentc8e1706e8dbe7a511c1fd85d5147a1722b4080f1 (diff)
parenta282a8f163fa70f9eacc880e6188141cef917058 (diff)
downloadgit-ec16dde5c8c08fe6f26a2183a038e02ea7b2b25f.tar.xz
Merge branch 'ps/packfile-store-in-odb-source' into ps/odb-for-each-object
* ps/packfile-store-in-odb-source: packfile: move MIDX into packfile store packfile: refactor `find_pack_entry()` to work on the packfile store packfile: inline `find_kept_pack_entry()` packfile: only prepare owning store in `packfile_store_prepare()` packfile: only prepare owning store in `packfile_store_get_packs()` packfile: move packfile store into object source packfile: refactor misleading code when unusing pack windows packfile: refactor kept-pack cache to work with packfile stores packfile: pass source to `prepare_pack()` packfile: create store via its owning source odb: properly close sources before freeing them builtin/gc: fix condition for whether to write commit graphs
Diffstat (limited to 'odb.c')
-rw-r--r--odb.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/odb.c b/odb.c
index ffd78e1c46..ac70b6a099 100644
--- a/odb.c
+++ b/odb.c
@@ -229,6 +229,7 @@ static struct odb_source *odb_source_new(struct object_database *odb,
source->local = local;
source->path = xstrdup(path);
source->loose = odb_source_loose_new(source);
+ source->packfiles = packfile_store_new(source);
return source;
}
@@ -376,6 +377,7 @@ static void odb_source_free(struct odb_source *source)
{
free(source->path);
odb_source_loose_free(source->loose);
+ packfile_store_free(source->packfiles);
free(source);
}
@@ -710,19 +712,19 @@ static int do_oid_object_info_extended(struct object_database *odb,
while (1) {
struct odb_source *source;
- if (!packfile_store_read_object_info(odb->packfiles, real, oi, flags))
- return 0;
-
/* Most likely it's a loose object. */
- for (source = odb->sources; source; source = source->next)
- if (!odb_source_loose_read_object_info(source, real, oi, flags))
+ for (source = odb->sources; source; source = source->next) {
+ if (!packfile_store_read_object_info(source->packfiles, real, oi, flags) ||
+ !odb_source_loose_read_object_info(source, real, oi, flags))
return 0;
+ }
/* Not a loose object; someone else may have just packed it. */
if (!(flags & OBJECT_INFO_QUICK)) {
odb_reprepare(odb->repo->objects);
- if (!packfile_store_read_object_info(odb->packfiles, real, oi, flags))
- return 0;
+ for (source = odb->sources; source; source = source->next)
+ if (!packfile_store_read_object_info(source->packfiles, real, oi, flags))
+ return 0;
}
/*
@@ -981,13 +983,14 @@ int odb_freshen_object(struct object_database *odb,
{
struct odb_source *source;
- if (packfile_store_freshen_object(odb->packfiles, oid))
- return 1;
-
odb_prepare_alternates(odb);
- for (source = odb->sources; source; source = source->next)
+ for (source = odb->sources; source; source = source->next) {
+ if (packfile_store_freshen_object(source->packfiles, oid))
+ return 1;
+
if (odb_source_loose_freshen_object(source, oid))
return 1;
+ }
return 0;
}
@@ -1062,7 +1065,6 @@ struct object_database *odb_new(struct repository *repo,
memset(o, 0, sizeof(*o));
o->repo = repo;
- o->packfiles = packfile_store_new(o);
pthread_mutex_init(&o->replace_mutex, NULL);
string_list_init_dup(&o->submodule_source_paths);
@@ -1082,15 +1084,8 @@ struct object_database *odb_new(struct repository *repo,
void odb_close(struct object_database *o)
{
struct odb_source *source;
-
- packfile_store_close(o->packfiles);
-
- for (source = o->sources; source; source = source->next) {
- if (source->midx)
- close_midx(source->midx);
- source->midx = NULL;
- }
-
+ for (source = o->sources; source; source = source->next)
+ packfile_store_close(source->packfiles);
close_commit_graph(o);
}
@@ -1117,14 +1112,13 @@ void odb_free(struct object_database *o)
oidmap_clear(&o->replace_map, 1);
pthread_mutex_destroy(&o->replace_mutex);
+ odb_close(o);
odb_free_sources(o);
for (size_t i = 0; i < o->cached_object_nr; i++)
free((char *) o->cached_objects[i].value.buf);
free(o->cached_objects);
- odb_close(o);
- packfile_store_free(o->packfiles);
string_list_clear(&o->submodule_source_paths, 0);
chdir_notify_unregister(NULL, odb_update_commondir, o);
@@ -1147,13 +1141,13 @@ void odb_reprepare(struct object_database *o)
o->loaded_alternates = 0;
odb_prepare_alternates(o);
- for (source = o->sources; source; source = source->next)
+ for (source = o->sources; source; source = source->next) {
odb_source_loose_reprepare(source);
+ packfile_store_reprepare(source->packfiles);
+ }
o->approximate_object_count_valid = 0;
- packfile_store_reprepare(o->packfiles);
-
obj_read_unlock();
}