Skip to content

Commit

Permalink
setup: set the_repository's hash algo when checking format
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bk2204 authored and gitster committed May 27, 2020
1 parent 4b83120 commit d553ace
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions setup.c
Expand Up @@ -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);
}

Expand Down

0 comments on commit d553ace

Please sign in to comment.