]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: set the_repository's hash algo when checking format
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 25 May 2020 19:59:08 +0000 (19:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 May 2020 17:07:06 +0000 (10:07 -0700)
When we're checking the repository's format, set the hash algorithm at
the same time.  This ensures that we perform a suitable initialization
early enough to avoid confusing any parts of the code.  If we defer
until later, we can end up with portions of the code which are confused
about the hash algorithm, resulting in segfaults when working with
SHA-256 repositories.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c

diff --git a/setup.c b/setup.c
index 65fe5ecefbe196eba04070978bc668b9af17257d..019a1c6367b02e02e8cd88ad28061d681b836bb5 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1273,6 +1273,7 @@ void check_repository_format(struct repository_format *fmt)
                fmt = &repo_fmt;
        check_repository_format_gently(get_git_dir(), fmt, NULL);
        startup_info->have_repository = 1;
+       repo_set_hash_algo(the_repository, fmt->hash_algo);
        clear_repository_format(&repo_fmt);
 }