Skip to content

Commit 7839b7f

Browse files
fin-wibhagwan
authored andcommitted
git branch: change default picker list
1 parent f2968f3 commit 7839b7f

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ M.defaults.git = {
536536
_treesitter = function(line) return line:match("(%s+)(%d+)%)(.+)$") end,
537537
},
538538
branches = {
539-
cmd = "git branch --all --color",
539+
cmd = [[git branch --all --color -vv ]]
540+
.. [[--sort=-'committerdate' --sort='refname:rstrip=-2' --sort=-'HEAD']],
540541
preview = "git log --graph --pretty=oneline --abbrev-commit --color {1}",
541542
remotes = "local",
542543
actions = {

lua/fzf-lua/providers/git.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,14 @@ M.branches = function(opts)
184184
if opts.preview then
185185
local preview = path.git_cwd(opts.preview, opts)
186186
opts.preview = shell.stringify_cmd(function(items)
187-
-- all possible options:
187+
-- The beginning of the selected line looks like the below,
188+
-- but we only want the string containing the branch name,
189+
-- so match the first sequence not including spaces:
188190
-- branch
189191
-- * branch
190192
-- remotes/origin/branch
191193
-- (HEAD detached at origin/branch)
192-
local branch = items[1]:match("[^%s%*]*$"):gsub("%)$", "")
194+
local branch = items[1]:match("^[%*+]*[%s]*[(]?([^%s)]+)")
193195
return (preview:gsub("{.*}", branch))
194196
end, opts, "{}")
195197
end

0 commit comments

Comments
 (0)