|
26 | 26 | #====================================================================================================================== |
27 | 27 | set -o nounset # Treat unset variables as an error |
28 | 28 |
|
29 | | -__ScriptVersion="2024.12.12" |
| 29 | +__ScriptVersion="2025.02.24" |
30 | 30 | __ScriptName="bootstrap-salt.sh" |
31 | 31 |
|
32 | 32 | __ScriptFullName="$0" |
@@ -2161,21 +2161,19 @@ __git_clone_and_checkout() { |
2161 | 2161 | fi |
2162 | 2162 |
|
2163 | 2163 | if [ "$__SHALLOW_CLONE" -eq $BS_TRUE ]; then |
2164 | | - # Let's try shallow cloning to speed up. |
2165 | | - # Test for "--single-branch" option introduced in git 1.7.10, the minimal version of git where the shallow |
| 2164 | + # Let's try 'treeless' cloning to speed up. Treeless cloning omits trees and blobs ('files') |
| 2165 | + # but includes metadata (commit history, tags, branches etc. |
| 2166 | + # Test for "--filter" option introduced in git 2.19, the minimal version of git where the treeless |
2166 | 2167 | # cloning we need actually works |
2167 | | - if [ "$(git clone 2>&1 | grep 'single-branch')" != "" ]; then |
2168 | | - # The "--single-branch" option is supported, attempt shallow cloning |
| 2168 | + if [ "$(git clone 2>&1 | grep 'filter')" != "" ]; then |
| 2169 | + # The "--filter" option is supported: attempt treeless cloning |
2169 | 2170 | echoinfo "Attempting to shallow clone $GIT_REV_ADJ from Salt's repository ${_SALT_REPO_URL}" |
2170 | | - ## Shallow cloning is resulting in the wrong version of Salt, even with a depth of 5 |
2171 | | - ## getting 3007.0+0na.246d066 when it should be 3007.1+410.g246d066457, disabling for now |
2172 | | - ## if git clone --depth 1 --branch "$GIT_REV_ADJ" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then |
2173 | | - echodebug "git command, git clone --branch $GIT_REV_ADJ $_SALT_REPO_URL $__SALT_CHECKOUT_REPONAME" |
2174 | | - if git clone --branch "$GIT_REV_ADJ" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then |
| 2171 | + echodebug "git command, git clone --filter=tree:0 --branch $GIT_REV_ADJ $_SALT_REPO_URL $__SALT_CHECKOUT_REPONAME" |
| 2172 | + if git clone --filter=tree:0 --branch "$GIT_REV_ADJ" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then |
2175 | 2173 | # shellcheck disable=SC2164 |
2176 | 2174 | cd "${_SALT_GIT_CHECKOUT_DIR}" |
2177 | 2175 | __SHALLOW_CLONE=$BS_TRUE |
2178 | | - echoinfo "shallow path (disabled shallow) git cloned $GIT_REV_ADJ, version $(python3 salt/version.py)" |
| 2176 | + echoinfo "shallow path git cloned $GIT_REV_ADJ, version $(python3 salt/version.py)" |
2179 | 2177 | else |
2180 | 2178 | # Shallow clone above failed(missing upstream tags???), let's resume the old behaviour. |
2181 | 2179 | echowarn "Failed to shallow clone." |
|
0 commit comments