From c30d3a61ddf08e691ca1f4d2dc17bfe0dc33d85e Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 31 Mar 2024 22:27:29 +0800 Subject: enable longpaths for submodule/reset #4905 --- xmake/modules/devel/git/submodule/reset.lua | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'xmake/modules/devel/git/submodule/reset.lua') 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 -- cgit v1.3.1