new file mode 100644
@@ -0,0 +1,23 @@
+# generate_random_blob <seed-string> [<size>]
+generate_random_blob () {
+ test-tool genrandom "$@" >blob &&
+ git hash-object -w -t blob blob &&
+ rm blob
+}
+
+# pack_random_blob <seed-string> [<size>]
+pack_random_blob () {
+ generate_random_blob "$@" &&
+ git repack -d -q >/dev/null
+}
+
+# generate_cruft_pack <seed-string> [<size>]
+generate_cruft_pack () {
+ pack_random_blob "$@" >/dev/null &&
+
+ ls $packdir/pack-*.pack | xargs -n 1 basename >in &&
+ pack="$(git pack-objects --cruft $packdir/pack <in)" &&
+ git prune-packed &&
+
+ echo "$packdir/pack-$pack.mtimes"
+}
@@ -3,6 +3,7 @@
test_description='git repack works correctly'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-cruft.sh
objdir=.git/objects
packdir=$objdir/pack
@@ -128,27 +129,6 @@ test_expect_success '--expire-to stores pruned objects (5.minutes.ago)' '
)
'
-generate_random_blob() {
- test-tool genrandom "$@" >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 <in)" &&
- git prune-packed &&
-
- echo "$packdir/pack-$pack.mtimes"
-}
-
test_expect_success '--max-cruft-size creates new packs when above threshold' '
git init max-cruft-size-large &&
(
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 <me@ttaylorr.com> --- 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