summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-31 22:27:29 +0800
committerruki <[email protected]>2024-03-31 22:27:44 +0800
commitc30d3a61ddf08e691ca1f4d2dc17bfe0dc33d85e (patch)
tree4a05b9e88f200b1a3cc7be05fb2609b745e17d56
parent479ebb1da2792c84758dea5d6b9a025fba47a9fc (diff)
enable longpaths for submodule/reset #4905
-rw-r--r--xmake/modules/devel/git/submodule/reset.lua24
-rw-r--r--xmake/modules/devel/git/submodule/update.lua4
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua10
3 files changed, 25 insertions, 13 deletions
diff --git a/xmake/modules/devel/git/submodule/reset.lua b/xmake/modules/devel/git/submodule/reset.lua
index e0c7bf98d..f3c5ca45a 100644
--- a/xmake/modules/devel/git/submodule/reset.lua
+++ b/xmake/modules/devel/git/submodule/reset.lua
@@ -36,11 +36,7 @@ import("lib.detect.find_tool")
-- @endcode
--
function main(opt)
-
- -- init options
opt = opt or {}
-
- -- find git
local git = assert(find_tool("git"), "git not found!")
-- init argv
@@ -79,6 +75,26 @@ function main(opt)
table.insert(argv, opt.commit)
end
+ -- enable long paths
+ local longpaths_old
+ local longpaths_changed = false
+ if opt.longpaths then
+ local longpaths_old = try {function () return os.iorunv(git.program, {"config", "--get", "--global", "core.longpaths"}, {curdir = opt.repodir}) end}
+ if not longpaths_old or not longpaths_old:find("true") then
+ os.vrunv(git.program, {"config", "--global", "core.longpaths", "true"}, {curdir = opt.repodir})
+ longpaths_changed = true
+ end
+ end
+
-- reset it
os.vrunv(git.program, argv, {curdir = opt.repodir})
+
+ -- restore old long paths configuration
+ if longpaths_changed then
+ if longpaths_old and longpaths_old:find("false") then
+ os.vrunv(git.program, {"config", "--global", "core.longpaths", "false"}, {curdir = opt.repodir})
+ else
+ os.vrunv(git.program, {"config", "--global", "--unset", "core.longpaths"}, {curdir = opt.repodir})
+ end
+ end
end
diff --git a/xmake/modules/devel/git/submodule/update.lua b/xmake/modules/devel/git/submodule/update.lua
index ee24bffcf..91f930b2d 100644
--- a/xmake/modules/devel/git/submodule/update.lua
+++ b/xmake/modules/devel/git/submodule/update.lua
@@ -36,11 +36,7 @@ import("lib.detect.find_tool")
-- @endcode
--
function main(opt)
-
- -- init options
opt = opt or {}
-
- -- find git
local git = assert(find_tool("git"), "git not found!")
-- init argv
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 0556e9f6a..988461e36 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -38,6 +38,9 @@ import("utils.archive")
function _checkout(package, url, sourcedir, opt)
opt = opt or {}
+ -- we need to enable longpaths on windows
+ local longpaths = package:policy("platform.longpaths")
+
-- use previous source directory if exists
local packagedir = path.join(sourcedir, package:name())
if os.isdir(path.join(packagedir, ".git")) and
@@ -50,7 +53,7 @@ function _checkout(package, url, sourcedir, opt)
-- clean and reset submodules
if os.isfile(path.join(packagedir, ".gitmodules")) then
git.submodule.clean({repodir = packagedir, force = true, all = true})
- git.submodule.reset({repodir = packagedir, hard = true})
+ git.submodule.reset({repodir = packagedir, hard = true, longpaths = longpaths})
end
tty.erase_line_to_start().cr()
return
@@ -71,7 +74,7 @@ function _checkout(package, url, sourcedir, opt)
git.reset({repodir = localdir, hard = true})
if os.isfile(path.join(localdir, ".gitmodules")) then
git.submodule.clean({repodir = localdir, force = true, all = true})
- git.submodule.reset({repodir = localdir, hard = true})
+ git.submodule.reset({repodir = localdir, hard = true, longpaths = longpaths})
end
os.cp(localdir, packagedir)
tty.erase_line_to_start().cr()
@@ -81,9 +84,6 @@ function _checkout(package, url, sourcedir, opt)
-- remove temporary directory
os.rm(sourcedir .. ".tmp")
- -- we need to enable longpaths on windows
- local longpaths = package:policy("platform.longpaths")
-
-- download package from branches?
packagedir = path.join(sourcedir .. ".tmp", package:name())
local branch = package:branch()