From 1a71141d85d221653c40b80efffef3e652ed3b07 Mon Sep 17 00:00:00 2001 From: Ryann Graham Date: Fri, 3 Nov 2023 09:47:21 -0700 Subject: [PATCH 1/2] check: use bare clone The check container doesn't make any use of an actual checkout, but on large repositories the time to checkout after fetching can be 90% or more of the overall time to clone. Because the --bare option prevents the --branch option from being setting the refspec in the config we have to do it as a follow-up step. Instead of relying solely on the config having the refspec set correctly, we can also explicitly specify the branch when fetching if one is set. Signed-off-by: Ryann Graham --- assets/check | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/check b/assets/check index 4a81bb1..b59e0ac 100755 --- a/assets/check +++ b/assets/check @@ -48,16 +48,20 @@ export GIT_LFS_SKIP_SMUDGE=1 if [ -d $destination ]; then cd $destination - git fetch $tagflag -f - git reset --hard FETCH_HEAD + git fetch origin $tagflag $branch -f + git reset --soft FETCH_HEAD else branchflag="" if [ -n "$branch" ]; then branchflag="--branch $branch" fi - git clone --single-branch $uri $branchflag $destination $tagflag + git clone --bare --single-branch $uri $branchflag $destination $tagflag cd $destination + # bare clones don't configure the refspec + if [ -n "$branch" ]; then + git remote set-branches --add origin $branch + fi fi if [ -n "$ref" ] && git cat-file -e "$ref"; then From c392e874d0a6e489e1a4951945eb02821474a74d Mon Sep 17 00:00:00 2001 From: Ryann Graham Date: Fri, 3 Nov 2023 09:51:52 -0700 Subject: [PATCH 2/2] check: use blobless partial clones The check operation doesn't need any blobs. The most detail is ever needs about commits is the paths they touched, which only requires commit and tree objects, not the blobs. On large repositories, especially with lots of history, this can dramatically reduce the time to clone and fetch while also dramatically reducing the server-side resources used to serve up those large git repositories. Signed-off-by: Ryann Graham --- assets/check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/check b/assets/check index b59e0ac..447a527 100755 --- a/assets/check +++ b/assets/check @@ -56,7 +56,7 @@ else branchflag="--branch $branch" fi - git clone --bare --single-branch $uri $branchflag $destination $tagflag + git clone --bare --filter=blob:none --single-branch $uri $branchflag $destination $tagflag cd $destination # bare clones don't configure the refspec if [ -n "$branch" ]; then