Skip to content

Commit

Permalink
Provide button to create and checkout new local branch for remote-onl… (
Browse files Browse the repository at this point in the history
#134)

* Provide button to create and checkout new local branch for remote-only branches

* new button works with remotes no named »origin«

* add regex for remote only branches

* Change concept for checkout of remote branches
  • Loading branch information
AlterDepp committed Aug 22, 2019
1 parent 89af431 commit a73599c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugin/gitv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,24 @@ fu! s:CheckOutGitvCommit() "{{{
if sha == ""
return
endif
let refs = allrefs + [sha]

" Modify refs to create and checkout new local branch for remote-only branches
let newrefs = []
for ref in allrefs
if (match(ref, '^r:') == 0) || (match(ref, '^refs/remotes/') == 0)
" Remove remote part
let ref = substitute(ref, '^r:\(\w\+\)/\(.*\)', '\2', '')
let ref = substitute(ref, '^refs\/remotes\/\(\w\+\)/\(.*\)', '\2', '')
if count(allrefs, ref) == 0
" Prevent dublicates
let newrefs += [ref]
endif
else
let newrefs += [ref]
endif
endfor

let refs = newrefs + [sha]
let refstr = s:GetConfirmString(refs, 'Cancel')
let choice = confirm("Checkout commit:", refstr)
if choice == 0
Expand Down

0 comments on commit a73599c

Please sign in to comment.