]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib: compute the compatibility hash so tests may use it
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 2 Oct 2023 02:40:31 +0000 (21:40 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Oct 2023 21:57:40 +0000 (14:57 -0700)
Inspired-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh

index 2f8868caa171d2d3ce78f3672e937ab7f8a3db97..92b462e2e7111ff9e0dea762ed32f43eb4249a30 100644 (file)
@@ -1599,7 +1599,16 @@ test_set_hash () {
 
 # Detect the hash algorithm in use.
 test_detect_hash () {
-       test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
+       case "$GIT_TEST_DEFAULT_HASH" in
+       "sha256")
+           test_hash_algo=sha256
+           test_compat_hash_algo=sha1
+           ;;
+       *)
+           test_hash_algo=sha1
+           test_compat_hash_algo=sha256
+           ;;
+       esac
 }
 
 # Load common hash metadata and common placeholder object IDs for use with
@@ -1651,6 +1660,12 @@ test_oid () {
        local algo="${test_hash_algo}" &&
 
        case "$1" in
+       --hash=storage)
+               algo="$test_hash_algo" &&
+               shift;;
+       --hash=compat)
+               algo="$test_compat_hash_algo" &&
+               shift;;
        --hash=*)
                algo="${1#--hash=}" &&
                shift;;