diff --git a/tools/tools/git/mfc-candidates.lua b/tools/tools/git/mfc-candidates.lua --- a/tools/tools/git/mfc-candidates.lua +++ b/tools/tools/git/mfc-candidates.lua @@ -117,41 +117,17 @@ local function usage(from_branch, to_branch, author) local script_name = arg[0]:match("([^/]+)$") - print(script_name .. " [-ah] [-f from_branch] [-t to_branch] [-u user] [-X exclude_file] [path ...]") + print(script_name .. " [-ah] [-f from_branch] [-r remote] [-t to_branch] [-u user] [-X exclude_file] [path ...]") print() params(from_branch, to_branch, author) end -- Main function local function main() - local from_branch = "freebsd/main" - local to_branch = "" + local remote = "freebsd" local author = os.getenv("USER") or "" local dirspec = nil - local url = exec_command("git remote get-url freebsd") - local freebsd_repo = string.match(url, "[^/]+$") - freebsd_repo = string.gsub(freebsd_repo, ".git$", "") - if freebsd_repo == "ports" or freebsd_repo == "freebsd-ports" then - local year = os.date("%Y") - local month = os.date("%m") - local qtr = math.ceil(month / 3) - to_branch = "freebsd/" .. year .. "Q" .. qtr - elseif freebsd_repo == "src" or freebsd_repo == "freebsd-src" then - to_branch = "freebsd/stable/14" - -- If pwd is a stable or release branch tree, default to it. - local cur_branch = exec_command("git symbolic-ref --short HEAD") - if string.match(cur_branch, "^stable/") then - to_branch = cur_branch - elseif string.match(cur_branch, "^releng/") then - to_branch = cur_branch - local major = string.match(cur_branch, "%d+") - from_branch = "freebsd/stable/" .. major - end - else - print("pwd is not under a ports or src repository.") - return - end local do_help = false local exclude_file = nil @@ -166,6 +142,9 @@ elseif opt == "-h" then do_help = true i = i + 1 + elseif opt == "-r" then + remote = arg[i + 1] + i = i + 1 elseif opt == "-t" then to_branch = arg[i + 1] i = i + 1 @@ -183,6 +162,32 @@ i = i + 1 end + local from_branch = remote .. "/main" + local to_branch = "" + local url = exec_command("git remote get-url " .. remote) + local freebsd_repo = string.match(url, "[^/^:]+$") + freebsd_repo = string.gsub(freebsd_repo, ".git$", "") + if freebsd_repo == "ports" or freebsd_repo == "freebsd-ports" then + local year = os.date("%Y") + local month = os.date("%m") + local qtr = math.ceil(month / 3) + to_branch = remote .. "/" .. year .. "Q" .. qtr + elseif freebsd_repo == "src" or freebsd_repo == "freebsd-src" then + to_branch = remote .. "/stable/14" + -- If pwd is a stable or release branch tree, default to it. + local cur_branch = exec_command("git symbolic-ref --short HEAD") + if string.match(cur_branch, "^stable/") then + to_branch = cur_branch + elseif string.match(cur_branch, "^releng/") then + to_branch = cur_branch + local major = string.match(cur_branch, "%d+") + from_branch = remote .. "/stable/" .. major + end + else + print("pwd is not under a ports or src repository.") + return + end + if do_help then usage(from_branch, to_branch, author) return