Skip to content

Commit 0ac7ee9

Browse files
pks-tgitster
authored andcommitted
builtin/grep: simplify how we preload packs
When using multiple threads in git-grep(1) we eagerly preload both the gitmodules file as well as the packfiles so that the threads won't race with one another to initialize these data structures. For packfiles, this is done by calling `packfile_store_get_packs()`, which first loads our packfiles and then returns a pointer to the first such packfile. This pointer is ignored though, as all we really care about is that `packfile_store_prepare()` was called. Historyically, that function was file-local to "packfile.c", but that changed with 4188332569 (packfile: move `get_multi_pack_index()` into "midx.c", 2025-09-02). We can thus simplify the code by calling that function directly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e69cdf4 commit 0ac7ee9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ int cmd_grep(int argc,
12141214
if (recurse_submodules)
12151215
repo_read_gitmodules(the_repository, 1);
12161216
if (startup_info->have_repository)
1217-
(void)packfile_store_get_packs(the_repository->objects->packfiles);
1217+
packfile_store_prepare(the_repository->objects->packfiles);
12181218

12191219
start_threads(&opt);
12201220
} else {

0 commit comments

Comments
 (0)