summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b791933ffd..596c549cdd 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1464,9 +1464,7 @@ test_set_hash () {
# Detect the hash algorithm in use.
test_detect_hash () {
- # Currently we only support SHA-1, but in the future this function will
- # actually detect the algorithm in use.
- test_hash_algo='sha1'
+ test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
}
# Load common hash metadata and common placeholder object IDs for use with
@@ -1515,7 +1513,17 @@ test_oid_cache () {
# Look up a per-hash value based on a key ($1). The value must have been loaded
# by test_oid_init or test_oid_cache.
test_oid () {
- local var="test_oid_${test_hash_algo}_$1" &&
+ local algo="${test_hash_algo}" &&
+
+ case "$1" in
+ --hash=*)
+ algo="${1#--hash=}" &&
+ shift;;
+ *)
+ ;;
+ esac &&
+
+ local var="test_oid_${algo}_$1" &&
# If the variable is unset, we must be missing an entry for this
# key-hash pair, so exit with an error.