From 57eeed25457252d0555ff2ec5858ad671714543c Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 21 Aug 2021 16:33:51 -0400 Subject: [PATCH] Add alternatives to :GBrowse ++remote= In the same way Vim requires custom commands to start with an uppercase letter, I'm starting to think we should self-impose the same constraint on custom ++options. Also, let's throw "Git" in there, just to allow this to be truly unique if necessary. This also allows a special remote argument of ".git" to refer to the local repository. A possible use of this would be a local gitweb handler. --- autoload/fugitive.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0c44359..9717cb6 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1170,7 +1170,9 @@ function! fugitive#RemoteUrl(...) abort else let url = remove(args, 0) endif - if url !~# ':\|^/\|^\.\.\=/' + if url ==# '.git' + let url = FugitiveGitDir(config) + elseif url !~# ':\|^/\|^\.\.\=/' let url = FugitiveConfigGet('remote.' . url . '.url', config) endif let instead_of = [] @@ -6794,11 +6796,11 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo let dir = s:Dir() try let arg = a:arg - if arg =~# '^++remote=' - let remote = matchstr(arg, '^++remote=\zs\S\+') + if arg =~# '^++\%([Gg]it\)\=[Rr]emote=' + let remote = matchstr(arg, '^++\%([Gg]it\)\=[Rr]emote=\zs\S\+') let arg = matchstr(arg, '\s\zs\S.*') endif - let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\=' + let validremote = '\.\%(git\)\=\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\=' if arg ==# '-' let remote = '' let rev = ''