Junio C Hamano <gitster@xxxxxxxxx> writes: > From: Patrick Steinhardt <ps@xxxxxx> > > 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