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>
brian m. carlson committed
Feb 22, 2020 at 20:17 UTC
192b517589fc927af6b01914c67cb6d1973a1c29
1 file changed
+14
-15
t/test-lib.sh
+14
-15
@@ -494,21 +494,6 @@ case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
494
;;
495
esac
496
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
-
497
# Line feed
498
LF='
499
'
@@ -1383,6 +1368,20 @@ then
1368
fi
1369
fi
1370
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
+
1385
# Provide an implementation of the 'yes' utility; the upper bound
1386
# limit is there to help Windows that cannot stop this loop from
1387
# wasting cycles when the downstream stops reading, so do not be