Handle FugitiveReal('') correctly

This commit is contained in:
Tim Pope 2018-07-28 19:31:11 -04:00
parent c5d4ce7479
commit 4643363b08
2 changed files with 3 additions and 3 deletions

View File

@ -511,7 +511,7 @@ function! fugitive#Real(url) abort
let tree = FugitiveTreeForGitDir(dir) let tree = FugitiveTreeForGitDir(dir)
return s:PlatformSlash((len(tree) ? tree : dir) . file) return s:PlatformSlash((len(tree) ? tree : dir) . file)
endif endif
let url = fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) let url = len(url) ? fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) : ''
if url =~# '^[\\/]\|^\a:[\\/]' if url =~# '^[\\/]\|^\a:[\\/]'
return s:PlatformSlash(url) return s:PlatformSlash(url)
endif endif
@ -519,7 +519,7 @@ function! fugitive#Real(url) abort
endfunction endfunction
function! fugitive#Path(url, ...) abort function! fugitive#Path(url, ...) abort
if !a:0 if !a:0 || empty(a:url)
return fugitive#Real(a:url) return fugitive#Real(a:url)
endif endif
let url = s:shellslash(fnamemodify(a:url, ':p')) let url = s:shellslash(fnamemodify(a:url, ':p'))

View File

@ -143,7 +143,7 @@ function! FugitiveReal(...) abort
let file = a:0 ? a:1 : @% let file = a:0 ? a:1 : @%
if file =~? '^fugitive:' || a:0 > 1 if file =~? '^fugitive:' || 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?[\/]$??'))