Skip to content

Commit

Permalink
feat(git_branches): switch remote as local (#1704)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Jan 10, 2025
1 parent c238e01 commit 369e2eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ previewers = {
prompt = 'Branches❯ ',
cmd = "git branch --all --color",
preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}",
remotes = "local", -- "detach|local", switch behavior for remotes
actions = {
["enter"] = actions.git_switch,
["ctrl-x"] = { fn = actions.git_branch_del, reload = true },
Expand Down
6 changes: 5 additions & 1 deletion lua/fzf-lua/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,11 @@ M.git_switch = function(selected, opts)
-- do nothing for active branch
if branch:find("%*") ~= nil then return end
if branch:find("^remotes/") then
table.insert(cmd, "--detach")
if opts.remotes == "detach" then
table.insert(cmd, "--detach")
else
branch = branch:match("remotes/.-/(.-)$")
end
end
table.insert(cmd, branch)
local output, rc = utils.io_systemlist(cmd)
Expand Down
1 change: 1 addition & 0 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ M.defaults.git = {
prompt = "Branches> ",
cmd = "git branch --all --color",
preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}",
remotes = "local",
actions = {
["enter"] = actions.git_switch,
["ctrl-x"] = { fn = actions.git_branch_del, reload = true },
Expand Down

0 comments on commit 369e2eb

Please sign in to comment.