rbong / vim-flog

A blazingly fast, stunningly beautiful, exceptionally powerful git branch viewer for Vim/Neovim.
750 stars 22 forks source link

Slash in branch name makes it appear as remote #124

Closed TamaMcGlinn closed 3 months ago

TamaMcGlinn commented 3 months ago

Today I tried to use flogmenu's delete branch to delete a local branch, called "feature/something", and it tried to do a git push to a remote called feature, to delete a branch called something. Flogmenu basically does this to get the remotes:

function! PrintRemotes() abort
  let l:commit = flog#floggraph#commit#GetAtLine()
  let refs = flog#state#GetCommitRefs(l:commit)
  let l:remote_branches = map(filter(copy(l:refs), 'v:val["remote"] != ""'), 'v:val.full')
  echom l:remote_branches
endfunction

To test it, source the above in your vim, then try :call PrintRemotes() inside a flog buffer pointing at a commit referenced by a feature/something branch.

I believe to properly handle this, we need to check in GetCommitRefs what all the remote names are, and count only valid remote names followed by slash as a remote.

rbong commented 3 months ago

I've noticed this as well but haven't had a chance to fix it. You're correct, the way to fix this is to check for valid remote names in GetCommitRefs. PRs welcome as I'm not sure when I'll get a chance for this.

rbong commented 3 months ago

Let me know if there's any problems with the fix I pushed out. Thanks again for reporting and the PR.