summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSirLynix <[email protected]>2024-01-24 15:52:21 +0100
committerSirLynix <[email protected]>2024-01-24 15:52:21 +0100
commit2642cdebef6642fb0fd69020a3b7084d62246b58 (patch)
tree6cbf6dd6314715f22559410187c36ac194bc7791
parent85bfb36d4e608662b74e5c42ac9e6a9052b3451e (diff)
Disable git core.autocrl on repositories and force pull
-rw-r--r--xmake/modules/devel/git/clone.lua9
-rw-r--r--xmake/modules/devel/git/pull.lua4
-rw-r--r--xmake/modules/private/action/require/impl/repository.lua6
3 files changed, 16 insertions, 3 deletions
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua
index a1e7ca8eb..bdd02caf1 100644
--- a/xmake/modules/devel/git/clone.lua
+++ b/xmake/modules/devel/git/clone.lua
@@ -115,6 +115,15 @@ function main(url, opt)
table.insert(argv, "core.fsmonitor=false")
end
+ -- set core.autocrlf
+ if opt.autocrlf then
+ table.insert(argv, "-c")
+ table.insert(argv, "core.autocrlf=true")
+ elseif opt.autocrlf == false then
+ table.insert(argv, "-c")
+ table.insert(argv, "core.autocrlf=false")
+ end
+
-- set outputdir
if opt.outputdir then
table.insert(argv, path.translate(opt.outputdir))
diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua
index f68e32279..63345f902 100644
--- a/xmake/modules/devel/git/pull.lua
+++ b/xmake/modules/devel/git/pull.lua
@@ -46,6 +46,10 @@ function main(opt)
-- init argv
local argv = {}
+ if opt.force then
+ table.insert(argv, "-f")
+ end
+
if opt.fsmonitor then
table.insert(argv, "-c")
table.insert(argv, "core.fsmonitor=true")
diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua
index 98cd45bd2..426a15e67 100644
--- a/xmake/modules/private/action/require/impl/repository.lua
+++ b/xmake/modules/private/action/require/impl/repository.lua
@@ -60,11 +60,11 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo)
local lastcommit
if not os.isdir(repodir_local) then
if repo_global then
- git.clone(repo_global:directory(), {verbose = option.get("verbose"), outputdir = repodir_local})
+ git.clone(repo_global:directory(), {verbose = option.get("verbose"), outputdir = repodir_local, autocrlf = false})
lastcommit = repo_global:commit()
elseif network ~= "private" then
local remoteurl = proxy.mirror(locked_repo.url) or locked_repo.url
- git.clone(remoteurl, {verbose = option.get("verbose"), branch = locked_repo.branch, outputdir = repodir_local})
+ git.clone(remoteurl, {verbose = option.get("verbose"), branch = locked_repo.branch, outputdir = repodir_local, autocrlf = false})
else
wprint("we cannot lock repository(%s) in private network mode!", locked_repo.url)
return
@@ -84,7 +84,7 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo)
if network ~= "private" then
-- pull the latest commit
local remoteurl = proxy.mirror(locked_repo.url) or locked_repo.url
- git.pull({verbose = option.get("verbose"), remote = remoteurl, branch = locked_repo.branch, repodir = repodir_local})
+ git.pull({verbose = option.get("verbose"), remote = remoteurl, branch = locked_repo.branch, repodir = repodir_local, force = true})
-- re-checkout to the given commit
ok = try {function () git.checkout(locked_repo.commit, {verbose = option.get("verbose"), repodir = repodir_local}); return true end}
else