Delegate to other real filename implementations

This commit is contained in:
Tim Pope 2018-08-06 01:21:19 -04:00
parent a3e9518186
commit 40e2dcba05
2 changed files with 11 additions and 6 deletions

View File

@ -488,16 +488,21 @@ function! s:DirRev(url) abort
endfunction endfunction
function! fugitive#Real(url) abort function! fugitive#Real(url) abort
if empty(a:url)
return ''
endif
let [dir, commit, file] = s:DirCommitFile(a:url) let [dir, commit, file] = s:DirCommitFile(a:url)
if len(dir) if len(dir)
let tree = s:Tree(dir) let tree = s:Tree(dir)
return s:PlatformSlash((len(tree) ? tree : dir) . file) return s:PlatformSlash((len(tree) ? tree : dir) . file)
endif endif
let url = len(a:url) ? fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) : '' let pre = substitute(matchstr(a:url, '^\a\a\+\ze:'), '^.', '\u&', '')
if url =~# '^[\\/]\|^\a:[\\/]' if len(pre) && pre !=? 'fugitive' && exists('*' . pre . 'Real')
return s:PlatformSlash(url) let url = {pre}Real(a:url)
else
let url = fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??'))
endif endif
return '' return s:PlatformSlash(empty(url) ? a:url : url)
endfunction endfunction
function! fugitive#Path(url, ...) abort function! fugitive#Path(url, ...) abort

View File

@ -34,9 +34,9 @@ endfunction
function! FugitiveReal(...) abort function! FugitiveReal(...) abort
let file = a:0 ? a:1 : @% let file = a:0 ? a:1 : @%
if file =~? '^fugitive:' || a:0 > 1 if file =~# '^\a\a\+:' || a:0 > 1
return call('fugitive#Real', [file] + a:000[1:-1]) return call('fugitive#Real', [file] + a:000[1:-1])
elseif file =~# '^/\|^\a\+:\|^$' elseif file =~# '^/\|^\a:\|^$'
return file return file
else else
return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??')) return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))