Skip to content

Commit 192b517

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9412759 commit 192b517

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

t/test-lib.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -494,21 +494,6 @@ case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
494494
;;
495495
esac
496496

497-
# Convenience
498-
#
499-
# A regexp to match 5, 35 and 40 hexdigits
500-
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
501-
_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
502-
_x40="$_x35$_x05"
503-
504-
# Zero SHA-1
505-
_z40=0000000000000000000000000000000000000000
506-
507-
OID_REGEX="$_x40"
508-
ZERO_OID=$_z40
509-
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
510-
EMPTY_BLOB=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
511-
512497
# Line feed
513498
LF='
514499
'
@@ -1383,6 +1368,20 @@ then
13831368
fi
13841369
fi
13851370

1371+
# Convenience
1372+
# A regexp to match 5, 35 and 40 hexdigits
1373+
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
1374+
_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
1375+
_x40="$_x35$_x05"
1376+
1377+
test_oid_init
1378+
1379+
ZERO_OID=$(test_oid zero)
1380+
OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g')
1381+
EMPTY_TREE=$(test_oid empty_tree)
1382+
EMPTY_BLOB=$(test_oid empty_blob)
1383+
_z40=$ZERO_OID
1384+
13861385
# Provide an implementation of the 'yes' utility; the upper bound
13871386
# limit is there to help Windows that cannot stop this loop from
13881387
# wasting cycles when the downstream stops reading, so do not be

0 commit comments

Comments
 (0)