Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve treeless for git.clone #5510

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!'
Expand Down
5 changes: 5 additions & 0 deletions xmake/modules/devel/git/clone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion xmake/modules/private/action/require/impl/repository.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading