t: add helper to convert object IDs to paths

There are several places in our testsuite where we want to insert a slash after an object ID to make it into a path we can reference under .git/objects, and we have various ways of doing so. Add a helper to provide a standard way of doing this that works for all size hashes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jun 28, 2019 at 22:59 UTC 56d889245984228aaba4d85f0afe94bd46fe59ab
1 file changed +6
t/test-lib-functions.sh
+6
@@ -1334,6 +1334,12 @@ test_oid () {
1334 eval "printf '%s' \"\${$var}\""
1335 }
1336
1337 +# Insert a slash into an object ID so it can be used to reference a location
1338 +# under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..".
1339 +test_oid_to_path () {
1340 + echo "${1%${1#??}}/${1#??}"
1341 +}
1342 +
1343 # Choose a port number based on the test script's number and store it in
1344 # the given variable name, unless that variable already contains a number.
1345 test_set_port () {