summaryrefslogtreecommitdiff
path: root/xmake/modules/devel/git/submodule/update.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-04-03 00:45:33 +0800
committerruki <[email protected]>2021-04-03 00:45:33 +0800
commite11df3dc74e9cd0c840b3474ee3b85092a094732 (patch)
tree27706eff0412b0093ffbc092ba38291c3753a0c6 /xmake/modules/devel/git/submodule/update.lua
parent9762bed68e2143e9c088813018c525f734cd8110 (diff)
add longpaths
Diffstat (limited to 'xmake/modules/devel/git/submodule/update.lua')
-rw-r--r--xmake/modules/devel/git/submodule/update.lua22
1 files changed, 21 insertions, 1 deletions
diff --git a/xmake/modules/devel/git/submodule/update.lua b/xmake/modules/devel/git/submodule/update.lua
index b75e391ca..5d9323a02 100644
--- a/xmake/modules/devel/git/submodule/update.lua
+++ b/xmake/modules/devel/git/submodule/update.lua
@@ -31,7 +31,7 @@ import("lib.detect.find_tool")
-- import("devel.git.submodule")
--
-- submodule.update({repodir = "/tmp/xmake", init = true, remote = true})
--- submodule.update({repodir = "/tmp/xmake", recursive = true, reference = "xxx", paths = "xxx"})
+-- submodule.update({repodir = "/tmp/xmake", recursive = true, longpaths = true, reference = "xxx", paths = "xxx"})
--
-- @endcode
--
@@ -64,9 +64,29 @@ function main(opt)
oldir = os.cd(opt.repodir)
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"}) end}
+ if not longpaths_old or not longpaths_old:find("true") then
+ os.vrunv(git.program, {"config", "--global", "core.longpaths", "true"})
+ longpaths_changed = true
+ end
+ end
+
-- submodule it
os.vrunv(git.program, argv)
+ -- 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"})
+ else
+ os.vrunv(git.program, {"config", "--global", "--unset", "core.longpaths"})
+ end
+ end
+
-- leave repository directory
if oldir then
os.cd(oldir)