From 253f8b39b4f1ee36212ea37bd05d879aa71fdbc2 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 9 Apr 2024 22:42:55 +0800 Subject: improve longpaths for submodules --- xmake/modules/devel/git/submodule/update.lua | 29 ++++++++-------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (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 91f930b2d..5ce9a6583 100644 --- a/xmake/modules/devel/git/submodule/update.lua +++ b/xmake/modules/devel/git/submodule/update.lua @@ -48,6 +48,13 @@ function main(opt) table.insert(argv, "-c") table.insert(argv, "core.fsmonitor=false") end + + -- use longpaths, we need it on windows + if opt.longpaths then + table.insert(argv, "-c") + table.insert(argv, "core.longpaths=true") + end + table.insert(argv, "submodule") table.insert(argv, "update") for _, name in ipairs({"init", "remote", "force", "checkout", "merge", "rebase", "recursive"}) do @@ -63,26 +70,6 @@ function main(opt) table.join2(argv, opt.paths) 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 - - -- submodule it + -- update 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 -- cgit v1.3.1