diff options
| author | brian m. carlson <sandals@crustytoothpaste.net> | 2019-06-28 22:59:19 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2019-07-01 13:28:18 -0700 |
| commit | 56d889245984228aaba4d85f0afe94bd46fe59ab (patch) | |
| tree | 628e041d9ab4274684c08439b2d14c74a8c73b8b /t/test-lib-functions.sh | |
| parent | The third batch (diff) | |
| download | git-56d889245984228aaba4d85f0afe94bd46fe59ab.tar.gz git-56d889245984228aaba4d85f0afe94bd46fe59ab.zip | |
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>
Diffstat (limited to 't/test-lib-functions.sh')
| -rw-r--r-- | t/test-lib-functions.sh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 0367cec5fd..7860491660 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1334,6 +1334,12 @@ test_oid () { eval "printf '%s' \"\${$var}\"" } +# Insert a slash into an object ID so it can be used to reference a location +# under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..". +test_oid_to_path () { + echo "${1%${1#??}}/${1#??}" +} + # Choose a port number based on the test script's number and store it in # the given variable name, unless that variable already contains a number. test_set_port () { |
