t5608: reduce maximum disk usage

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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 6, 2026 at 08:23 UTC bc1854f525ecc07043ccf131d18217adb926c876
1 file changed +35 -31
t/t5608-clone-2gb.sh
+35 -31
@@ -10,45 +10,47 @@ then
10 fi
11
12 test_expect_success 'setup' '
13 -
14 - git config pack.compression 0 &&
15 - git config pack.depth 0 &&
16 - blobsize=$((100*1024*1024)) &&
17 - blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
18 - i=1 &&
19 - (while test $i -le $blobcount
20 - do
21 - printf "Generating blob $i/$blobcount\r" >&2 &&
22 - printf "blob\nmark :$i\ndata $blobsize\n" &&
23 - #test-tool genrandom $i $blobsize &&
24 - printf "%-${blobsize}s" $i &&
25 - echo "M 100644 :$i $i" >> commit &&
26 - i=$(($i+1)) ||
27 - echo $? > exit-status
28 - done &&
29 - echo "commit refs/heads/main" &&
30 - echo "author A U Thor <author@email.com> 123456789 +0000" &&
31 - echo "committer C O Mitter <committer@email.com> 123456789 +0000" &&
32 - echo "data 5" &&
33 - echo ">2gb" &&
34 - cat commit) |
35 - git fast-import --big-file-threshold=2 &&
36 - test ! -f exit-status
37 -
13 + git init 2gb-repo &&
14 + (
15 + cd 2gb-repo &&
16 + git config pack.compression 0 &&
17 + git config pack.depth 0 &&
18 + blobsize=$((100*1024*1024)) &&
19 + blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
20 + i=1 &&
21 + (while test $i -le $blobcount
22 + do
23 + printf "Generating blob $i/$blobcount\r" >&2 &&
24 + printf "blob\nmark :$i\ndata $blobsize\n" &&
25 + #test-tool genrandom $i $blobsize &&
26 + printf "%-${blobsize}s" $i &&
27 + echo "M 100644 :$i $i" >> commit &&
28 + i=$(($i+1)) ||
29 + echo $? > exit-status
30 + done &&
31 + echo "commit refs/heads/main" &&
32 + echo "author A U Thor <author@email.com> 123456789 +0000" &&
33 + echo "committer C O Mitter <committer@email.com> 123456789 +0000" &&
34 + echo "data 5" &&
35 + echo ">2gb" &&
36 + cat commit) |
37 + git fast-import --big-file-threshold=2 &&
38 + test ! -f exit-status
39 + )
40 '
41
42 test_expect_success 'clone - bare' '
41 -
42 - git clone --bare --no-hardlinks . clone-bare
43 -
43 + test_when_finished rm -rf clone-bare &&
44 + git clone --bare --no-hardlinks 2gb-repo clone-bare
45 '
46
47 test_expect_success 'clone - with worktree, file:// protocol' '
47 -
48 - git clone "file://$(pwd)" clone-wt
49 -
48 + test_when_finished rm -rf clone-wt &&
49 + git clone "file://$(pwd)/2gb-repo" clone-wt
50 '
51
52 +rm -rf 2gb-repo 2>/dev/null
53 +
54 test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'set up repo with >4GB object' '
55 large_blob_size=$((4*1024*1024*1024+1)) &&
56 git init --bare 4gb-repo &&
@@ -61,6 +63,7 @@ test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'set up repo with >4GB object' '
63 '
64
65 test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'clone >4GB object via unpack-objects' '
66 + test_when_finished rm -rf 4gb-clone-unpack &&
67 # The synthesized pack has five objects, so a large unpack limit keeps
68 # fetch-pack on the unpack-objects path.
69 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
80 '
81
82 test_expect_success SIZE_T_IS_64BIT,EXPENSIVE 'clone with >4GB object via index-pack' '
83 + test_when_finished rm -rf 4gb-clone-index &&
84 # Force fetch-pack to hand the pack to index-pack instead.
85 git -c fetch.unpackLimit=1 clone --bare \
86 "file://$(pwd)/4gb-repo" 4gb-clone-index &&