fix snacks picker for git changed files
This commit is contained in:
@@ -239,10 +239,16 @@ return {
|
||||
end
|
||||
|
||||
-- Get the default branch
|
||||
local function branch_exists(branch)
|
||||
local result = git_cmd("git rev-parse --verify refs/remotes/origin/" .. branch)
|
||||
-- If branch exists, rev-parse returns a hash; if not, it returns fatal error
|
||||
return not result:match("^fatal")
|
||||
end
|
||||
|
||||
local default_branch = nil
|
||||
if git_cmd("git show-ref --verify --quiet refs/remotes/origin/main") == "" then
|
||||
if branch_exists("main") then
|
||||
default_branch = "main"
|
||||
elseif git_cmd("git show-ref --verify --quiet refs/remotes/origin/master") == "" then
|
||||
elseif branch_exists("master") then
|
||||
default_branch = "master"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user