diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 6eb841d..ab6d489 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -428,7 +428,7 @@ call s:add_methods('repo',['keywordprg']) " Section: Buffer function! s:UrlSplit(path) abort - let vals = matchlist(s:shellslash(a:path), '\c^fugitive://\(.\{-\}\)//\(\w\+\)\(/.*\)\=$') + let vals = matchlist(s:shellslash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\w\+\)\(/.*\)\=$') if empty(vals) return ['', '', ''] endif @@ -527,7 +527,7 @@ function! s:buffer_name() dict abort endfunction function! s:buffer_commit() dict abort - return matchstr(self.spec(),'^fugitive://.\{-\}//\zs\w*') + return matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs\w*') endfunction function! s:cpath(path) abort @@ -539,7 +539,7 @@ function! s:cpath(path) abort endfunction function! s:buffer_path(...) dict abort - let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*') + let rev = matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*') if rev != '' let rev = s:sub(rev,'\w*','') elseif s:cpath(self.spec()[0 : len(self.repo().dir())]) ==# @@ -554,7 +554,7 @@ function! s:buffer_path(...) dict abort endfunction function! s:buffer_rev() dict abort - let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*') + let rev = matchstr(self.spec(),'^fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*') if rev =~ '^\x/' return ':'.rev[0].':'.rev[2:-1] elseif rev =~ '.' @@ -569,7 +569,7 @@ function! s:buffer_rev() dict abort endfunction function! s:buffer_sha1() dict abort - if self.spec() =~ '^fugitive://' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$' + if self.spec() =~? '^fugitive:' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$' return self.repo().rev_parse(self.rev()) else return '' @@ -2219,9 +2219,9 @@ function! s:Browse(bang,line1,count,...) abort endif let full = s:repo().translate(expanded) let commit = '' - if full =~# '^fugitive://' - let commit = matchstr(full,'://.*//\zs\w\w\+') - let path = matchstr(full,'://.*//\w\+\zs/.*') + if full =~? '^fugitive:' + let commit = matchstr(full,':\%(//\)\=.*\%(//\|::\)\zs\w\w\+') + let path = matchstr(full,':\%(//\)\=.*\%(//\|::\)\w\+\zs/.*') if commit =~ '..' let type = s:repo().git_chomp('cat-file','-t',commit.s:sub(path,'^/',':')) let branch = matchstr(expanded, '^[^:]*') @@ -2567,7 +2567,7 @@ endfunction function! fugitive#FileRead() abort try let repo = s:repo(FugitiveExtractGitDir(expand(''))) - let path = s:sub(s:sub(matchstr(expand(''),'fugitive://.\{-\}//\zs.*'),'/',':'),'^\d:',':&') + let path = s:sub(s:sub(matchstr(expand(''),'fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*'),'/',':'),'^\d:',':&') let hash = repo.rev_parse(path) if path =~ '^:' let type = 'blob' diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 8d522c3..8ca07bc 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -59,8 +59,8 @@ endfunction function! FugitiveExtractGitDir(path) abort let path = s:shellslash(a:path) - if path =~# '^fugitive://.*//' - return matchstr(path, '\C^fugitive://\zs.\{-\}\ze//') + if path =~# '^fugitive:' + return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)') elseif isdirectory(path) let path = fnamemodify(path, ':p:s?/$??') else