From 460a30dc4f6260e5d7237b156d820fb10688f464 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 14 Dec 2024 09:38:32 -0800
Subject: [PATCH] Added `--depth 1` flag for cloning external libraries (thanks
@gxost!)
---
external/Get-GitModules.ps1 | 9 +++++++--
external/download.sh | 9 ++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/external/Get-GitModules.ps1 b/external/Get-GitModules.ps1
index c43f63756..a2791616b 100644
--- a/external/Get-GitModules.ps1
+++ b/external/Get-GitModules.ps1
@@ -14,8 +14,13 @@
[String] $PathRegex = "path\s*=\s*(?<path>.*)"
[String] $URLRegex = "url\s*=\s*(?<url>.*)"
[String] $BranchRegex = "branch\s*=\s*(?<Branch>.*)"
+[String] $Arguments = $($args -join " ")
#------- Script ----------------------------------------------------------------
+if ([string]::IsNullOrEmpty($Arguments)) {
+ $Arguments = "--depth 1"
+}
+
foreach ($Line in Get-Content $PSScriptRoot\..\.gitmodules) {
if ($Line -match $PathRegex) {
$Match = Select-String -InputObject $Line -Pattern $PathRegex
@@ -29,8 +34,8 @@ foreach ($Line in Get-Content $PSScriptRoot\..\.gitmodules) {
$Match = Select-String -InputObject $Line -Pattern $BranchRegex
$Branch = $Match.Matches[0].Groups[1].Value
- Write-Host "git clone $URL $Path -b $Branch --recursive" `
+ Write-Host "git clone --filter=blob:none $URL $Path -b $Branch --recursive $Arguments" `
-ForegroundColor Blue
- git clone $URL $PSScriptRoot/../$Path -b $Branch --recursive
+ git clone --filter=blob:none $URL $PSScriptRoot/../$Path -b $Branch --recursive $Arguments
}
}
diff --git a/external/download.sh b/external/download.sh
index 5cd14a4df..ebfc5fbe2 100755
--- a/external/download.sh
+++ b/external/download.sh
@@ -2,6 +2,8 @@
set -e
+ARGUMENTS="$*"
+
cd $(dirname "$0")/..
cat .gitmodules | \
while true; do
@@ -12,5 +14,10 @@ while true; do
url=$3
read line; set -- $line
branch=$3
- git clone $url $path -b $branch --recursive
+
+ if [ -z "$ARGUMENTS" ]; then
+ ARGUMENTS="--depth 1"
+ fi
+
+ git clone --filter=blob:none $url $path -b $branch --recursive $ARGUMENTS
done