Skip to content

Commit 7bfa9a6

Browse files
pks-tgitster
authored andcommitted
packfile: only prepare owning store in packfile_store_prepare()
When calling `packfile_store_prepare()` we prepare not only the provided packfile store, but also all those of all other sources part of the same object database. This was required when the store was still sitting on the object database level. But now that it sits on the source level it's not anymore. Refactor the code so that we only prepare the single packfile store passed by the caller. Adapt callers accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 12d0464 commit 7bfa9a6

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

builtin/grep.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,12 +1213,14 @@ int cmd_grep(int argc,
12131213
*/
12141214
if (recurse_submodules)
12151215
repo_read_gitmodules(the_repository, 1);
1216-
/*
1217-
* Note: `packfile_store_prepare()` prepares stores from all
1218-
* sources. This will be fixed in a subsequent commit.
1219-
*/
1220-
if (startup_info->have_repository)
1221-
packfile_store_prepare(the_repository->objects->sources->packfiles);
1216+
1217+
if (startup_info->have_repository) {
1218+
struct odb_source *source;
1219+
1220+
odb_prepare_alternates(the_repository->objects);
1221+
for (source = the_repository->objects->sources; source; source = source->next)
1222+
packfile_store_prepare(source->packfiles);
1223+
}
12221224

12231225
start_threads(&opt);
12241226
} else {

packfile.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,16 +1063,11 @@ static int sort_pack(const struct packfile_list_entry *a,
10631063

10641064
void packfile_store_prepare(struct packfile_store *store)
10651065
{
1066-
struct odb_source *source;
1067-
10681066
if (store->initialized)
10691067
return;
10701068

1071-
odb_prepare_alternates(store->source->odb);
1072-
for (source = store->source->odb->sources; source; source = source->next) {
1073-
prepare_multi_pack_index_one(source);
1074-
prepare_packed_git_one(source);
1075-
}
1069+
prepare_multi_pack_index_one(store->source);
1070+
prepare_packed_git_one(store->source);
10761071

10771072
sort_packs(&store->packs.head, sort_pack);
10781073
for (struct packfile_list_entry *e = store->packs.head; e; e = e->next)
@@ -2098,15 +2093,11 @@ static int find_pack_entry(struct repository *r,
20982093
{
20992094
struct odb_source *source;
21002095

2101-
/*
2102-
* Note: `packfile_store_prepare()` prepares stores from all sources.
2103-
* This will be fixed in a subsequent commit.
2104-
*/
2105-
packfile_store_prepare(r->objects->sources->packfiles);
2106-
2107-
for (source = r->objects->sources; source; source = source->next)
2096+
for (source = r->objects->sources; source; source = source->next) {
2097+
packfile_store_prepare(r->objects->sources->packfiles);
21082098
if (source->midx && fill_midx_entry(source->midx, oid, e))
21092099
return 1;
2100+
}
21102101

21112102
for (source = r->objects->sources; source; source = source->next) {
21122103
struct packfile_list_entry *l;

0 commit comments

Comments
 (0)