Skip to content

Commit ec4380f

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d8be89 commit ec4380f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

packfile.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -935,22 +935,17 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
935935
report_garbage(PACKDIR_FILE_GARBAGE, full_name);
936936
}
937937

938-
static void prepare_packed_git_one(struct repository *r, char *objdir, int local)
938+
static void prepare_packed_git_one(struct odb_source *source, int local)
939939
{
940-
struct prepare_pack_data data;
941940
struct string_list garbage = STRING_LIST_INIT_DUP;
941+
struct prepare_pack_data data = {
942+
.m = source->midx,
943+
.r = source->odb->repo,
944+
.garbage = &garbage,
945+
.local = local,
946+
};
942947

943-
data.m = r->objects->multi_pack_index;
944-
945-
/* look for the multi-pack-index for this object directory */
946-
while (data.m && strcmp(data.m->object_dir, objdir))
947-
data.m = data.m->next;
948-
949-
data.r = r;
950-
data.garbage = &garbage;
951-
data.local = local;
952-
953-
for_each_file_in_pack_dir(objdir, prepare_pack, &data);
948+
for_each_file_in_pack_dir(source->path, prepare_pack, &data);
954949

955950
report_pack_garbage(data.garbage);
956951
string_list_clear(data.garbage, 0);
@@ -1040,7 +1035,7 @@ static void prepare_packed_git(struct repository *r)
10401035
for (source = r->objects->sources; source; source = source->next) {
10411036
int local = (source == r->objects->sources);
10421037
prepare_multi_pack_index_one(source, local);
1043-
prepare_packed_git_one(r, source->path, local);
1038+
prepare_packed_git_one(source, local);
10441039
}
10451040
rearrange_packed_git(r);
10461041

0 commit comments

Comments
 (0)