t: use hash-specific lookup tables to define test constants

In the future, we'll allow developers to run the testsuite with a hash
algorithm of their choice.  To make this easier, compute the fixed
constants using test_oid. Move the constant initialization down below
the point where test-lib-functions.sh is loaded so the functions are
defined.

Note that we don't provide a value for the OID_REGEX value directly
because writing a large number of instances of "[0-9a-f]" in the
oid-info files is unwieldy and there isn't a way to compute it based on
those values. Instead, compute it based on ZERO_OID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2020-02-22 20:17:31 +00:00 коммит произвёл Junio C Hamano
Родитель 9412759925
Коммит 192b517589
1 изменённых файлов: 14 добавлений и 15 удалений

Просмотреть файл

@ -494,21 +494,6 @@ case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
;; ;;
esac esac
# Convenience
#
# A regexp to match 5, 35 and 40 hexdigits
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
_x40="$_x35$_x05"
# Zero SHA-1
_z40=0000000000000000000000000000000000000000
OID_REGEX="$_x40"
ZERO_OID=$_z40
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
# Line feed # Line feed
LF=' LF='
' '
@ -1383,6 +1368,20 @@ then
fi fi
fi fi
# Convenience
# A regexp to match 5, 35 and 40 hexdigits
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
_x40="$_x35$_x05"
test_oid_init
ZERO_OID=$(test_oid zero)
OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g')
EMPTY_TREE=$(test_oid empty_tree)
EMPTY_BLOB=$(test_oid empty_blob)
_z40=$ZERO_OID
# Provide an implementation of the 'yes' utility; the upper bound # Provide an implementation of the 'yes' utility; the upper bound
# limit is there to help Windows that cannot stop this loop from # limit is there to help Windows that cannot stop this loop from
# wasting cycles when the downstream stops reading, so do not be # wasting cycles when the downstream stops reading, so do not be