[PATCH 6/7] t1092: set up repositories from templates
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 6, 2026, 10:30 UTC
- Message-ID
- <20261106-pks-gitlab-ci-speedups-v1-6-1fa0374c7287@pks.im>
- In-Reply-To
- <20261106-pks-gitlab-ci-speedups-v1-0-1fa0374c7287@pks.im>
In t1092 we verify the behaviour of sparse checkouts. We use three different repositories to do so: one with a full checkout, one with a sparse checkout and one with a sparse index, and then verify that the result is the same across all these configurations.
Those repositories get set up via `init_repos ()`, which initializes them from scratch every single time with a bunch of processes. The function is called more than a 100 times though, so the overhead adds up quite a bit. While the tests only require around 30 seconds on Linux, it takes more than 10 minutes on Windows.
Optimize this by instead creating the repositories once, only. So instead of recreating them from scratch, we can then just copy the template repositories into place and thus save a bunch of processes. This speeds up tests on Windows by about 3 minutes.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- t/t1092-sparse-checkout-compatibility.sh | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 05b54062b3b..5d81ec54c23 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -141,28 +141,34 @@ test_expect_success 'setup' ' ) ' +test_expect_success 'setup template repositories' ' + cp -r initial-repo full-checkout.template && + cp -r initial-repo sparse-checkout.template && + cp -r initial-repo sparse-index.template && + + # initialize sparse-checkout definitions + git -C sparse-checkout.template sparse-checkout init --cone && + git -C sparse-checkout.template sparse-checkout set deep && + git -C sparse-index.template sparse-checkout init --cone --sparse-index && + test_cmp_config -C sparse-index.template true index.sparse && + git -C sparse-index.template sparse-checkout set deep && + + # Disable this message to keep stderr the same. + git -C sparse-index.template config advice.sparseIndexExpanded false +' + init_repos () { rm -rf full-checkout sparse-checkout sparse-index && # create repos in initial state - cp -r initial-repo full-checkout && + cp -r full-checkout.template full-checkout && git -C full-checkout reset --hard && - cp -r initial-repo sparse-checkout && + cp -r sparse-checkout.template sparse-checkout && git -C sparse-checkout reset --hard && - cp -r initial-repo sparse-index && - git -C sparse-index reset --hard && - - # initialize sparse-checkout definitions - git -C sparse-checkout sparse-checkout init --cone && - git -C sparse-checkout sparse-checkout set deep && - git -C sparse-index sparse-checkout init --cone --sparse-index && - test_cmp_config -C sparse-index true index.sparse && - git -C sparse-index sparse-checkout set deep && - - # Disable this message to keep stderr the same. - git -C sparse-index config advice.sparseIndexExpanded false + cp -r sparse-index.template sparse-index && + git -C sparse-index reset --hard } init_repos_as_submodules () {
-- 2.56.0.500.g5d06dc02cd.dirty