diff --git a/scripts/get.sh b/scripts/get.sh index 4b9c80156da..d5238cd216c 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -203,7 +203,7 @@ elif test_eq "$branch" "__run__"; then else echo "cloning $gitrepo $branch .." if test_nz "$2"; then - git clone --depth=50 -b "$branch" "$gitrepo" --recurse-submodules $projectdir || raise "clone failed, check your network or branch name" + git clone --filter=tree:0 --no-checkout -b "$branch" "$gitrepo" --recurse-submodules $projectdir || raise "clone failed, check your network or branch name" cd $projectdir || raise 'chdir failed!' git checkout -qf "$2" cd - || raise 'chdir failed!' diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index cc0b8f841ab..eceb8071447 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -93,6 +93,11 @@ function main(url, opt) table.insert(argv, "--filter=tree:0") end + -- no checkout + if opt.checkout == false then + table.insert(argv, "--no-checkout") + end + -- recursive? if opt.recursive then table.insert(argv, "--recursive") diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index fc3045aa277..9e04d07a982 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -121,7 +121,8 @@ function _checkout(package, url, sourcedir, opt) else -- clone whole history and tags - git.clone(url, {longpaths = longpaths, outputdir = packagedir}) + -- @see https://github.com/xmake-io/xmake/issues/5507 + git.clone(url, {treeless = true, checkout = false, longpaths = longpaths, outputdir = packagedir}) -- attempt to checkout the given version git.checkout(revision, {repodir = packagedir}) diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua index 048e4b2732e..e21b0e0913f 100644 --- a/xmake/modules/private/action/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -72,7 +72,7 @@ function _checkout(package, resource_name, resource_url, resource_revision) local longpaths = package:policy("platform.longpaths") -- clone whole history and tags - git.clone(resource_url, {longpaths = longpaths, outputdir = resourcedir}) + git.clone(resource_url, {treeless = true, checkout = false, longpaths = longpaths, outputdir = resourcedir}) -- attempt to checkout the given version git.checkout(resource_revision, {repodir = resourcedir}) diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua index 593ae5ebe20..68f4ccb6d32 100644 --- a/xmake/modules/private/action/require/impl/repository.lua +++ b/xmake/modules/private/action/require/impl/repository.lua @@ -60,7 +60,7 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo) local lastcommit if not os.isdir(repodir_local) then if repo_global then - git.clone(repo_global:directory(), {verbose = option.get("verbose"), outputdir = repodir_local, autocrlf = false}) + git.clone(repo_global:directory(), {treeless = true, checkout = false, verbose = option.get("verbose"), outputdir = repodir_local, autocrlf = false}) lastcommit = repo_global:commit() elseif network ~= "private" then local remoteurl = proxy.mirror(locked_repo.url) or locked_repo.url