]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repository: stop reading loose object map twice on repo init
authorPatrick Steinhardt <ps@pks.im>
Tue, 26 May 2026 05:57:02 +0000 (07:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 May 2026 11:07:03 +0000 (20:07 +0900)
When initializing a repository via `repo_init()` we end up reading the
loose object map twice:

  - `apply_repository_format()` calls `repo_set_compat_hash_algo()`,
    which in turn calls `repo_read_loose_object_map()` if we have a
    compatibility hash configured.

  - `repo_init()` calls `repo_read_loose_object_map()` directly a second
    time.

Drop the second read of the loose object map in `repo_init()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
repository.c

index 2c2395105fcf2d5c99009962e1d3162c057d3241..61dfbb8be6cd1d06663a175120fee7a41471fec6 100644 (file)
@@ -301,9 +301,6 @@ int repo_init(struct repository *repo,
        if (worktree)
                repo_set_worktree(repo, worktree);
 
-       if (repo->compat_hash_algo)
-               repo_read_loose_object_map(repo);
-
        clear_repository_format(&format);
        strbuf_release(&err);
        return 0;