aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-15 13:29:19 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-15 12:07:28 -0700
commitec4380f446b76e931002481f3e4be520c77058b6 (patch)
treeaafaa6127563d11cc5723298a34f79bdcf9f99f1
parent4d8be89d973b69a826911385c5cf3d40d347394b (diff)
downloadgit-ec4380f446b76e931002481f3e4be520c77058b6.tar.gz
packfile: refactor `prepare_packed_git_one()` to work on sources
In the preceding commit we refactored how we load multi-pack indices to take a corresponding "source" as input. As part of this refactoring we started to store a pointer to the MIDX in `struct odb_source` itself. Refactor loading of packfiles in the same way: instead of passing in the object directory, we now pass in the source from which we want to load packfiles. This allows us to simplify the code because we don't have to search for a corresponding MIDX anymore, but we can instead directly use the MIDX that we have already prepared beforehand. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--packfile.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/packfile.c b/packfile.c
index 8bdd85fc7e..0b3142973b 100644
--- a/packfile.c
+++ b/packfile.c
@@ -935,22 +935,17 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
report_garbage(PACKDIR_FILE_GARBAGE, full_name);
}
-static void prepare_packed_git_one(struct repository *r, char *objdir, int local)
+static void prepare_packed_git_one(struct odb_source *source, int local)
{
- struct prepare_pack_data data;
struct string_list garbage = STRING_LIST_INIT_DUP;
+ struct prepare_pack_data data = {
+ .m = source->midx,
+ .r = source->odb->repo,
+ .garbage = &garbage,
+ .local = local,
+ };
- data.m = r->objects->multi_pack_index;
-
- /* look for the multi-pack-index for this object directory */
- while (data.m && strcmp(data.m->object_dir, objdir))
- data.m = data.m->next;
-
- data.r = r;
- data.garbage = &garbage;
- data.local = local;
-
- for_each_file_in_pack_dir(objdir, prepare_pack, &data);
+ for_each_file_in_pack_dir(source->path, prepare_pack, &data);
report_pack_garbage(data.garbage);
string_list_clear(data.garbage, 0);
@@ -1040,7 +1035,7 @@ static void prepare_packed_git(struct repository *r)
for (source = r->objects->sources; source; source = source->next) {
int local = (source == r->objects->sources);
prepare_multi_pack_index_one(source, local);
- prepare_packed_git_one(r, source->path, local);
+ prepare_packed_git_one(source, local);
}
rearrange_packed_git(r);