commit d39d5ca4299569a5d1a37a511d1a5eccef71b037 (tree)
parent bb548813881924618b2e9d1b4f8c9917bd886408
Author: Tim Pope <code@tpope.net>
Date: Fri, 15 Jun 2018 23:10:05 -0400
Accept alternate forms of Fugitive URL
This is to prepare for a potential transition to a URL replacement that
isn't mutilated by simplify().
Diffstat:
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git 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('<amatch>')))
- let path = s:sub(s:sub(matchstr(expand('<amatch>'),'fugitive://.\{-\}//\zs.*'),'/',':'),'^\d:',':&')
+ let path = s:sub(s:sub(matchstr(expand('<amatch>'),'fugitive:\%(//\)\=.\{-\}\%(//\|::\)\zs.*'),'/',':'),'^\d:',':&')
let hash = repo.rev_parse(path)
if path =~ '^:'
let type = 'blob'
diff --git 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