File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 = {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments