diff options
| author | ruki <[email protected]> | 2024-08-26 23:27:49 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-26 23:27:49 +0800 |
| commit | ce3d162f72ae7e2f65a7ad85c0e52e195302a14b (patch) | |
| tree | 353b9b2824f5a5760db53bbb110280f34f6f4bc4 | |
| parent | 5aeee42d72b7c2289a0179821db04c36751fc38e (diff) | |
| parent | af3ce4a3ac449e430a7e3a28fa1323d7304ff0bc (diff) | |
Merge pull request #5510 from xmake-io/treeless
improve treeless for git.clone
5 files changed, 10 insertions, 4 deletions
diff --git a/scripts/get.sh b/scripts/get.sh index 4b9c80156..d5238cd21 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 cc0b8f841..eceb80714 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 fc3045aa2..9e04d07a9 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 048e4b273..e21b0e091 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 593ae5ebe..68f4ccb6d 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 |
