From: Eric Sunshine Date: Sun, 26 Jul 2020 23:52:00 GMT Subject: Re: [PATCH v4 36/39] t: make SHA1 prerequisite depend on default hash Message-ID: In-Reply-To: <20200726195424.626969-37-sandals@crustytoothpaste.net> On Sun, Jul 26, 2020 at 3:56 PM brian m. carlson wrote: > Currently, the SHA1 prerequisite depends on the output of git > hash-object. However, in order for that to produce sane behavior, we > must be in a repository. If we are not, the default will remain SHA-1, > and we'll produce wrong results if we're using SHA-256 for the testsuite > but the test assertion starts when we're not in a repository. > > Check the environment variable we use for this purpose, leaving it to > default to SHA-1 if none is specified. > > Signed-off-by: brian m. carlson > --- > diff --git a/t/test-lib.sh b/t/test-lib.sh > @@ -1689,7 +1689,8 @@ test_lazy_prereq CURL ' > test_lazy_prereq SHA1 ' > + test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 && > + { test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1"; } > ' Do we even need to run git-hash-object if GIT_DEFAULT_HASH is defined? That is, why not something like this instead? case "$GIT_DEFAULT_HASH" in sha1) true ;; "") test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ;; *) false ;; esac