[PATCH v2 4/7] t0027: optimize how we reset repository state
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 9, 2026, 09:58 UTC
- Message-ID
- <20261109-pks-gitlab-ci-speedups-v2-4-508832602d0b@pks.im>
- In-Reply-To
- <20261109-pks-gitlab-ci-speedups-v2-0-508832602d0b@pks.im>
In t0027 we verify our logic to convert CRLF for all kinds of combinations of attributes and configuration, which ultimately results in 2600 test cases. This is of course on the heavier side, so on Windows this takes more than 10 minutes to run.
One source of slowness is `checkout_files ()`, which gets called for a lot of our test to set up the initial working directory. As part of that we both remove the old files that we care about and then check them out again via git-checkout(1), but we do this one by one for every single file.
This is of course rather wasteful, as we have to spawn ten different processes every time the function is invoked. And on top of that, we also have to rewrite the complete index in git-checkout(1) every time.
Speed this up by instead using a single invocation of rm(1) and git-checkout(1). This reduces the runtime by about 20% on all platforms, and on Windows this reduces the runtime by ~2.5 minutes.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- t/t0027-auto-crlf.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index 49dbf09da77..504a7ea54bb 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -305,11 +305,12 @@ checkout_files () { pfx=eol_${ceol}_crlf_${crlf}_attr_${attr}_ && for f in LF CRLF LF_mix_CR CRLF_mix_LF LF_nul do - test_expect_success "setup $f checkout ${ceol:+ with -c core.eol=$ceol}" ' - rm -f crlf_false_attr__$f.txt && - git ${ceol:+-c core.eol=$ceol} checkout -- crlf_false_attr__$f.txt - ' + paths="${paths:+"$paths "}crlf_false_attr__$f.txt" done + test_expect_success "setup checkout ${ceol:+ with -c core.eol=$ceol}" ' + rm -f $paths && + git ${ceol:+-c core.eol=$ceol} checkout -- $paths + ' test_expect_success "ls-files --eol attr=$attr $ident aeol=$aeol core.autocrlf=$crlf core.eol=$ceol" ' test_when_finished "rm expect actual" &&
-- 2.56.0.611.g1030f0b940.dirty