From: Taylor Blau Date: Tue, 11 Mar 2025 00:21:44 GMT Subject: [PATCH v4 3/6] t/lib-cruft.sh: extract some cruft-related helpers Message-ID: In-Reply-To: The test script in t7704-repack-cruft.sh uses a handful of helpers to generate and pack random blobs, but a forthcoming test in t5329 will want to make use of generate_random_blob(). Instead of rewriting that function, move it (and the related helpers) to its own reusable library to avoid duplicating the function. Signed-off-by: Taylor Blau --- t/lib-cruft.sh | 23 +++++++++++++++++++++++ t/t7704-repack-cruft.sh | 22 +--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 t/lib-cruft.sh diff --git a/t/lib-cruft.sh b/t/lib-cruft.sh new file mode 100644 index 0000000000..9fdc0b01b0 --- /dev/null +++ b/t/lib-cruft.sh @@ -0,0 +1,23 @@ +# generate_random_blob [] +generate_random_blob () { + test-tool genrandom "$@" >blob && + git hash-object -w -t blob blob && + rm blob +} + +# pack_random_blob [] +pack_random_blob () { + generate_random_blob "$@" && + git repack -d -q >/dev/null +} + +# generate_cruft_pack [] +generate_cruft_pack () { + pack_random_blob "$@" >/dev/null && + + ls $packdir/pack-*.pack | xargs -n 1 basename >in && + pack="$(git pack-objects --cruft $packdir/pack blob && - git hash-object -w -t blob blob && - rm blob -} - -pack_random_blob () { - generate_random_blob "$@" && - git repack -d -q >/dev/null -} - -generate_cruft_pack () { - pack_random_blob "$@" >/dev/null && - - ls $packdir/pack-*.pack | xargs -n 1 basename >in && - pack="$(git pack-objects --cruft $packdir/pack