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
@@ -199,10 +199,6 @@ test_expect_success 'too-short tree' '
|
||||
test_i18ngrep "too-short tree object" err
|
||||
'
|
||||
|
||||
hex2oct() {
|
||||
perl -ne 'printf "\\%03o", hex for /../g'
|
||||
}
|
||||
|
||||
test_expect_success 'malformed mode in tree' '
|
||||
hex_sha1=$(echo foo | git hash-object --stdin -w) &&
|
||||
bin_sha1=$(echo $hex_sha1 | hex2oct) &&
|
||||
|
||||
Reference in New Issue
Block a user