git_branches: better remote branches detection

This commit is contained in:
bhagwan 2021-09-08 17:08:39 -07:00
parent 5de5638d37
commit 81ed9c4d6b

View File

@ -239,7 +239,8 @@ M.git_switch = function(selected, opts)
-- do nothing for active branch -- do nothing for active branch
if branch:find("%*") ~= nil then return end if branch:find("%*") ~= nil then return end
local args = "" local args = ""
if branch:find("/") ~= nil then args = "--detach " end local is_remote = branch:find("^remotes/") ~= nil
if is_remote then args = "--detach " end
local output = vim.fn.systemlist(cmd .. args .. branch) local output = vim.fn.systemlist(cmd .. args .. branch)
if utils.shell_error() then if utils.shell_error() then
utils.err(unpack(output)) utils.err(unpack(output))