[PATCH v2 4/9] t5608: reduce maximum disk usage
From: Patrick Steinhardt <hidden>
Date: 2026-07-03 09:24:27
Subsystem:
the rest · Maintainer:
Linus Torvalds
The tests in t5608 perform a couple of clones of repositories that are somewhat large. Ultimately, we end up creating: - A setup repository that contains 2GB of uncompressed pack data. - A bare clone that contains the same 2GB of data. - A clone with worktree writes a 2GB packfile and a 2GB worktree. - A second setup repository that contains a 4GB packfile. - Two 4GB clone of that repository. Some of these clones ultimately hardlink files, which ensures that we at least don't end up with more than 20GB of data. But at the end of the test we still have around 16GB of data, which is only a tiny bit better. Refactor the test to prune repositories after they have no use anymore. This reduced the peak disk usage of this test to 8GB. Signed-off-by: Patrick Steinhardt <redacted> --- t/t5608-clone-2gb.sh | 66 ++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 31 deletions(-)
diff --git a/t/t5608-clone-2gb.sh b/t/t5608-clone-2gb.sh
index 4f8a95ddda..5d56debf1c 100755
--- a/t/t5608-clone-2gb.sh
+++ b/t/t5608-clone-2gb.sh@@ -10,45 +10,47 @@ then fi test_expect_success 'setup' ' - - git config pack.compression 0 && - git config pack.depth 0 && - blobsize=$((100*1024*1024)) && - blobcount=$((2*1024*1024*1024/$blobsize+1)) && - i=1 && - (while test $i -le $blobcount - do - printf "Generating blob $i/$blobcount\r" >&2 && - printf "blob\nmark :$i\ndata $blobsize\n" && - #test-tool genrandom $i $blobsize && - printf "%-${blobsize}s" $i && - echo "M 100644 :$i $i" >> commit && - i=$(($i+1)) || - echo $? > exit-status - done && - echo "commit refs/heads/main" && - echo "author A U Thor <author@email.com> 123456789 +0000" && - echo "committer C O Mitter <committer@email.com> 123456789 +0000" && - echo "data 5" && - echo ">2gb" && - cat commit) | - git fast-import --big-file-threshold=2 && - test ! -f exit-status - + git init 2gb-repo && + ( + cd 2gb-repo && + git config pack.compression 0 && + git config pack.depth 0 && + blobsize=$((100*1024*1024)) && + blobcount=$((2*1024*1024*1024/$blobsize+1)) && + i=1 && + (while test $i -le $blobcount + do + printf "Generating blob $i/$blobcount\r" >&2 && + printf "blob\nmark :$i\ndata $blobsize\n" && + #test-tool genrandom $i $blobsize && + printf "%-${blobsize}s" $i && + echo "M 100644 :$i $i" >> commit && + i=$(($i+1)) || + echo $? > exit-status + done && + echo "commit refs/heads/main" && + echo "author A U Thor <author@email.com> 123456789 +0000" && + echo "committer C O Mitter <committer@email.com> 123456789 +0000" && + echo "data 5" && + echo ">2gb" && + cat commit) | + git fast-import --big-file-threshold=2 && + test ! -f exit-status + ) ' test_expect_success 'clone - bare' ' - - git clone --bare --no-hardlinks . clone-bare - + test_when_finished rm -rf clone-bare && + git clone --bare --no-hardlinks 2gb-repo clone-bare ' test_expect_success 'clone - with worktree, file:// protocol' ' - - git clone "file://$(pwd)" clone-wt - + test_when_finished rm -rf clone-wt && + git clone "file://$(pwd)/2gb-repo" clone-wt ' +rm -rf 2gb-repo 2>/dev/null + test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'set up repo with >4GB object' ' large_blob_size=$((4*1024*1024*1024+1)) && git init --bare 4gb-repo &&
@@ -61,6 +63,7 @@ test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'set up repo with >4GB object' ' ' test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'clone >4GB object via unpack-objects' ' + test_when_finished rm -rf 4gb-clone-unpack && # The synthesized pack has five objects, so a large unpack limit keeps # fetch-pack on the unpack-objects path. git -c fetch.unpackLimit=100 clone --bare \
@@ -77,6 +80,7 @@ test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'clone >4GB object via unpack-obje ' test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'clone with >4GB object via index-pack' ' + test_when_finished rm -rf 4gb-clone-index && # Force fetch-pack to hand the pack to index-pack instead. git -c fetch.unpackLimit=1 clone --bare \ "file://$(pwd)/4gb-repo" 4gb-clone-index &&
--
2.55.0.795.g602f6c329a.dirty