fix snacks picker for git changed files

This commit is contained in:
Thomas G. Lopes
2026-03-11 09:58:17 +00:00
parent e20775f834
commit 74d21792b5
+8 -2
View File
@@ -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