Re: [PATCH v4 4/5] builtin/hash-object: fix uninitialized hash function
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 17, 2024, 23:49 UTC
- Message-ID
- <xmqqmsoodmoe.fsf@gitster.g>
- In-Reply-To
- <20240514011437.3779151-5-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> From: Patrick Steinhardt <ps@pks.im> > > The git-hash-object(1) command allows users to hash an object even > without a repository. Starting with c8aed5e8da (repository: stop setting > SHA1 as the default object hash, 2024-05-07), this will make us hit an > uninitialized hash function, which subsequently leads to a segfault. > > Fix this by falling back to SHA-1 explicitly when running outside of > a Git repository. Users can use GIT_DEFAULT_HASH environment to > specify what hash algorithm they want, so arguably this code should > not be needed.
By the way, this breaks the expectation of t1007 and t1517 when run with GIT_DEFAULT_HASH=sha256 (I recall that they passed with the earlier iteration of my "fall back to GIT_DEFAULT_HASH" in [1/5], but we decided abusing GIT_DEFAULT_HASH is a bad idea).
https://github.com/git/git/actions/runs/9135149292/job/25122031380