t: move 'hex2oct' into test-lib-functions.sh
The helper 'hex2oct' is used to convert base-16 encoded data into a base-8 binary form, and is useful for preparing data for commands that accept input in a binary format, such as 'git hash-object', via 'printf'. This helper is defined identically in three separate places throughout 't'. Move the definition to test-lib-function.sh, so that it can be used in new test suites, and its definition is not redundant. This will likewise make our job easier in the subsequent commit, which also uses 'hex2oct'. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
aeb582a983
commit
5c07647d98
@ -1202,6 +1202,12 @@ depacketize () {
|
||||
'
|
||||
}
|
||||
|
||||
# Converts base-16 data into base-8. The output is given as a sequence of
|
||||
# escaped octals, suitable for consumption by 'printf'.
|
||||
hex2oct () {
|
||||
perl -ne 'printf "\\%03o", hex for /../g'
|
||||
}
|
||||
|
||||
# Set the hash algorithm in use to $1. Only useful when testing the testsuite.
|
||||
test_set_hash () {
|
||||
test_hash_algo="$1"
|
||||
|
||||
Reference in New Issue
Block a user