packfile: pass source to `prepare_pack()`
When preparing a packfile we pass various pieces attached to the pack's object database source via the `struct prepare_pack_data`. Refactor this code to instead pass in the source directly. This reduces the number of variables we need to pass and allows for a subsequent refactoring where we start to prepare the pack via the source. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jan 9, 2026 at 09:33 UTC
0316c63ca4fc0d58ecd02243c62253b246fd046a
1 file changed
+5
-9
packfile.c
+5
-9
@@ -975,10 +975,8 @@ void for_each_file_in_pack_dir(const char *objdir,
975
}
976
977
struct prepare_pack_data {
978
- struct repository *r;
978
+ struct odb_source *source;
979
struct string_list *garbage;
980
- int local;
981
- struct multi_pack_index *m;
980
};
981
982
static void prepare_pack(const char *full_name, size_t full_name_len,
@@ -988,10 +986,10 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
986
size_t base_len = full_name_len;
987
988
if (strip_suffix_mem(full_name, &base_len, ".idx") &&
991
- !(data->m && midx_contains_pack(data->m, file_name))) {
989
+ !(data->source->midx && midx_contains_pack(data->source->midx, file_name))) {
990
char *trimmed_path = xstrndup(full_name, full_name_len);
993
- packfile_store_load_pack(data->r->objects->packfiles,
994
- trimmed_path, data->local);
991
+ packfile_store_load_pack(data->source->odb->packfiles,
992
+ trimmed_path, data->source->local);
993
free(trimmed_path);
994
}
995
@@ -1020,10 +1018,8 @@ static void prepare_packed_git_one(struct odb_source *source)
1018
{
1019
struct string_list garbage = STRING_LIST_INIT_DUP;
1020
struct prepare_pack_data data = {
1023
- .m = source->midx,
1024
- .r = source->odb->repo,
1021
+ .source = source,
1022
.garbage = &garbage,
1026
- .local = source->local,
1023
};
1024
1025
for_each_file_in_pack_dir(source->path, prepare_pack, &data);