diff options
| author | ruki <[email protected]> | 2025-04-06 12:12:20 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-06 12:12:20 +0800 |
| commit | 89a5cfda8ba1bd10caa02978474b320081cb87b0 (patch) | |
| tree | 70cd7a2bc9083d4dcd555959c75b7304007690b2 | |
| parent | a201afae4ca719b3a13743eb42c2f348a858c697 (diff) | |
| parent | 5030bcbc98b252dcba7726bb531c3468078858fe (diff) | |
Merge pull request #6288 from Elite-stay/fix-older-git
Fix git clone failure
| -rw-r--r-- | xmake/modules/devel/git/clone.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index 27e8e49b1..7b7964216 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -52,6 +52,20 @@ function can_shallow_submodules() return can or false end +-- can clone with --filter=tree:0? +-- @see https://github.com/xmake-io/xmake/issues/6246 +function can_treeless() + local can = _g.can_treeless + if can == nil then + local git = assert(find_tool("git", {version = true}), "git not found!") + if git.version and semver.compare(git.version, "2.16.0") >= 0 then + can = true + end + _g.can_treeless = can or false + end + return can or false +end + -- clone url -- -- @param url the git url @@ -89,7 +103,7 @@ function main(url, opt) -- treeless? -- @see https://github.com/xmake-io/xmake/issues/5507 - if opt.treeless then + if opt.treeless and can_treeless() then table.insert(argv, "--filter=tree:0") end |
