]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: make SHA1 prerequisite depend on default hash
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 29 Jul 2020 23:14:25 +0000 (23:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jul 2020 16:16:49 +0000 (09:16 -0700)
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 <sandals@crustytoothpaste.net>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index 307bb2207e55dff9351b91ad22fbab1b3a7b3563..0483ed51e16079047b0e8f99d9a3602ce9141d98 100644 (file)
@@ -1689,7 +1689,11 @@ test_lazy_prereq CURL '
 # which will not work with other hash algorithms and tests that work but don't
 # test anything meaningful (e.g. special values which cause short collisions).
 test_lazy_prereq SHA1 '
-       test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
+       case "$GIT_DEFAULT_HASH" in
+       sha1) true ;;
+       "") test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 ;;
+       *) false ;;
+       esac
 '
 
 test_lazy_prereq REBASE_P '