Message ID | 20200513005424.81369-24-sandals@crustytoothpaste.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SHA-256 part 2/3: protocol functionality | expand |
On Wed, 13 May 2020 at 02:56, brian m. carlson <sandals@crustytoothpaste.net> wrote: > > 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. This doesn't make a difference as long as you just use SHA-1, right? That is, this isn't a bug in the first half of this series nor in v2.27-rc0 as long as you stick to SHA-1? > --- 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); > } Martin
On 2020-05-16 at 11:03:56, Martin Ågren wrote: > On Wed, 13 May 2020 at 02:56, brian m. carlson > <sandals@crustytoothpaste.net> wrote: > > > > 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. > > This doesn't make a difference as long as you just use SHA-1, right? > That is, this isn't a bug in the first half of this series nor in > v2.27-rc0 as long as you stick to SHA-1? Correct, because the default is SHA-1 if no algorithm is specified. I'll update the commit message to reflect that this affects only SHA-256.
diff --git a/setup.c b/setup.c index 65fe5ecefb..019a1c6367 100644 --- 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); }
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. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> --- setup.c | 1 + 1 file changed, 1 insertion(+)