Skip to content

Commit

Permalink
test-lib: compute the compatibility hash so tests may use it
Browse files Browse the repository at this point in the history
Inspired-by: brian m. carlson <[email protected]>
Signed-off-by: "Eric W. Biederman" <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
ebiederm authored and gitster committed Oct 2, 2023
1 parent c68be1f commit 48b16ab
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;;
Expand Down

0 comments on commit 48b16ab

Please sign in to comment.