From 74a095d76643eddc01fbf00f738d61a81f94530a Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Thu, 28 Feb 2019 20:14:17 +0100 Subject: [PATCH] use generic_git helper functions Signed-off-by: Tobias Ulmer --- generic/generic_git.lua | 17 +++++++++-------- global/e2-fetch-project.lua | 6 +++--- global/e2-install-e2.lua | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/generic/generic_git.lua b/generic/generic_git.lua index 1eceadd..52aa328 100644 --- a/generic/generic_git.lua +++ b/generic/generic_git.lua @@ -396,7 +396,7 @@ function generic_git.git_init_db1(rurl, shared) end gitdir = e2lib.join("/", u.path); - gitargv = { "--git-dir="..gitdir, "init-db" } + gitargv = generic_git.git_new_argv(gitdir, false, "init-db") if shared then table.insert(gitargv, "--shared") end @@ -457,7 +457,7 @@ function generic_git.git_push1(gitdir, rurl, refspec) return false, e:cat(re) end - argv = { "--git-dir=" .. gitdir, "push", remote_git_url, refspec } + argv = generic_git.git_new_argv(gitdir, nil, "push", remote_git_url, refspec) rc, re = generic_git.git(argv) if not rc then return false, e:cat(re) @@ -496,8 +496,7 @@ function generic_git.git_remote_add1(lurl, rurl, name) end gitdir = e2lib.join("/", lrepo.path) - argv = { "--git-dir="..gitdir, "remote", "add", name, giturl } - + argv = generic_git.git_new_argv(gitdir, nil, "remote", "add", name, giturl) rc, re = generic_git.git(argv) if not rc then return false, re @@ -837,19 +836,21 @@ function generic_git.new_repository(c, lserver, llocation, rserver, rlocation) return false, e:cat(re) end - rc, re = generic_git.git_remote_add(c, lserver, llocation, "origin", rserver, rlocation) + rc, re = generic_git.git_remote_add( + c, lserver, llocation, generic_git.refs_remote(), rserver, rlocation) if not rc then return false, e:cat(re) end - argv = { "--git-dir="..gitdir, "config", "branch.master.remote", "origin" } + argv = generic_git.git_new_argv( + gitdir, nil, "config", "branch.master.remote", generic_git.refs_remote()) rc, re = generic_git.git(argv) if not rc then return false, e:cat(re) end - argv = { "--git-dir="..gitdir, "config", "branch.master.merge", - refs_heads("master") } + argv = generic_git.git_new_argv( + gitdir, nil, "config", "branch.master.merge", refs_heads("master")) rc, re = generic_git.git(argv) if not rc then return false, e:cat(re) diff --git a/global/e2-fetch-project.lua b/global/e2-fetch-project.lua index a8be637..b206542 100644 --- a/global/e2-fetch-project.lua +++ b/global/e2-fetch-project.lua @@ -157,13 +157,13 @@ local function e2_fetch_project(arg) -- Because the repository is freshly cloned, we can assume that when a -- ref for the requested branch exists, HEAD is at that branch. rc, re, id = generic_git.lookup_id(e2lib.join(p.destdir, ".git"), - false, "refs/heads/" .. p.branch) + false, generic_git.refs_heads(p.branch)) if not rc then error(e:cat(re)) end if not id then rc, re = generic_git.git_branch_new1(p.destdir, true, p.branch, - "origin/" .. p.branch) + generic_git.refs_remote_heads(p.branch)) if not rc then error(e:cat(re)) end @@ -188,7 +188,7 @@ local function e2_fetch_project(arg) p.tag, p.branch) end - rc, re = generic_git.git_checkout1(p.destdir, "refs/tags/" .. p.tag) + rc, re = generic_git.git_checkout1(p.destdir, generic_git.refs_tags(p.tag)) if not rc then error(e:cat(re)) end diff --git a/global/e2-install-e2.lua b/global/e2-install-e2.lua index eb02d1a..c27e758 100644 --- a/global/e2-install-e2.lua +++ b/global/e2-install-e2.lua @@ -121,10 +121,10 @@ local function e2_install_e2(arg) if e2version.branch:match("/") then ref = e2version.branch else - ref = string.format("remotes/origin/%s", e2version.branch) + ref = generic_git.refs_remotes(e2version.branch) end else - ref = string.format("refs/tags/%s", e2version.tag) + ref = generic_git.refs_tags(e2version.tag) end -- checkout e2factory itself @@ -146,7 +146,7 @@ local function e2_install_e2(arg) for _,ex in ipairs(extensions) do if not ex.ref:match("/") then - ex.ref = string.format("refs/tags/%s", ex.ref) + ex.ref = generic_git.refs_tags(ex.ref) end e2lib.logf(2, "fetching extension: %s (%s)", ex.name, ex.ref) local server = config.site.e2_server -- 2.39.5