Skip to content

Commit 56d8892

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8dca754 commit 56d8892

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

t/test-lib-functions.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,12 @@ test_oid () {
13341334
eval "printf '%s' \"\${$var}\""
13351335
}
13361336

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+
13371343
# Choose a port number based on the test script's number and store it in
13381344
# the given variable name, unless that variable already contains a number.
13391345
test_set_port () {

0 commit comments

Comments
 (0)