Skip to content

Commit b6869f5

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 9a37c88 commit b6869f5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

packfile.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,8 @@ void for_each_file_in_pack_dir(const char *objdir,
975975
}
976976

977977
struct prepare_pack_data {
978-
struct repository *r;
978+
struct odb_source *source;
979979
struct string_list *garbage;
980-
int local;
981-
struct multi_pack_index *m;
982980
};
983981

984982
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,
988986
size_t base_len = full_name_len;
989987

990988
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))) {
992990
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);
995993
free(trimmed_path);
996994
}
997995

@@ -1020,10 +1018,8 @@ static void prepare_packed_git_one(struct odb_source *source)
10201018
{
10211019
struct string_list garbage = STRING_LIST_INIT_DUP;
10221020
struct prepare_pack_data data = {
1023-
.m = source->midx,
1024-
.r = source->odb->repo,
1021+
.source = source,
10251022
.garbage = &garbage,
1026-
.local = source->local,
10271023
};
10281024

10291025
for_each_file_in_pack_dir(source->path, prepare_pack, &data);

0 commit comments

Comments
 (0)