Files
git-mirror/t/lib-cat-file.sh
Eric Ju fb60c49d18 t1006: extract helper functions into new 'lib-cat-file.sh'
Extract utility functions from the cat-file's test script
't1006-cat-file.sh' into a new 'lib-cat-file.sh' dedicated library file.

A subsequent commit will need these functions. This improves the code
reuse and readability, enabling future cat-file tests to share these
helpers without duplicating code.

While at it update the style of this line to follow coding
guidelines:

. "$TEST_DIRECTORY/lib-loose.sh"

to

. "$TEST_DIRECTORY"/lib-loose.sh

Signed-off-by: Eric Ju <eric.peijian@gmail.com>
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-24 08:46:58 -07:00

17 lines
400 B
Bash

# Library of git-cat-file related test functions.
# Print a string without a trailing newline.
echo_without_newline () {
printf '%s' "$*"
}
# Print a string without newlines and replace them with a NUL character (\0).
echo_without_newline_nul () {
echo_without_newline "$@" | tr '\n' '\0'
}
# Calculate the length of a string.
strlen () {
echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
}