diff options
| author | brian m. carlson <sandals@crustytoothpaste.net> | 2020-07-29 23:14:23 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-07-30 09:16:49 -0700 |
| commit | ceaa4b3ad7f1927fdfa8164e1bfecece4da48329 (patch) | |
| tree | d644106e02dca1220a32cc010faeba3351128178 /t/test-lib-functions.sh | |
| parent | repository: enable SHA-256 support by default (diff) | |
| download | git-ceaa4b3ad7f1927fdfa8164e1bfecece4da48329.tar.gz git-ceaa4b3ad7f1927fdfa8164e1bfecece4da48329.zip | |
t: add test_oid option to select hash algorithm
In some tests, we have data files which are written with a particular
hash algorithm. Instead of keeping two copies of the test files, we can
keep one, and translate the value on the fly.
In order to do so, we'll need to read both the source algorithm and the
current algorithm, so add an optional flag to the test_oid helper that
lets us look up a value for a specified hash algorithm. This should
not cause any conflicts with existing tests, since key arguments to
test_oid are allowed to contains only shell identifier characters.
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>
Diffstat (limited to 't/test-lib-functions.sh')
| -rw-r--r-- | t/test-lib-functions.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3103be8a32..2608e80f11 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1468,7 +1468,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. |
