From e11df3dc74e9cd0c840b3474ee3b85092a094732 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 3 Apr 2021 00:45:33 +0800 Subject: add longpaths --- xmake/modules/devel/git/submodule/update.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'xmake/modules/devel/git/submodule/update.lua') 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) -- cgit v1.3.1