diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 3aa4491..12c0507 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -520,19 +520,21 @@ function! s:DirRev(url) abort return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')] endfunction -function! fugitive#Path(url) abort +function! fugitive#Real(url) abort let [dir, commit, file] = s:DirCommitFile(a:url) if len(dir) let tree = FugitiveTreeForGitDir(dir) return s:PlatformSlash((len(tree) ? tree : dir) . file) - elseif a:url =~# '^[\\/]\|^\a:[\\/]' - return s:PlatformSlash(a:url) + endif + let url = fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??')) + if url =~# '^[\\/]\|^\a:[\\/]' + return s:PlatformSlash(url) endif return '' endfunction -function! fugitive#Real(url) abort - return fugitive#Path(a:url) +function! fugitive#Path(url) abort + return fugitive#Real(a:url) endfunction let s:trees = {} @@ -2329,7 +2331,7 @@ function! s:BlameCommit(cmd) abort let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]') let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') if path ==# '' - let path = s:buffer(b:fugitive_blamed_bufnr).relative('') + let path = fugitive#Path(bufname(b:fugitive_blamed_bufnr), '') endif execute cmd if search('^diff .* b/\M'.escape(path,'\').'$','W') @@ -2370,7 +2372,7 @@ function! s:BlameJump(suffix) abort let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]') let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') if path ==# '' - let path = s:buffer(b:fugitive_blamed_bufnr).relative('') + let path = fugitive#Path(bufname(b:fugitive_blamed_bufnr), '') endif let args = b:fugitive_blame_arguments let offset = line('.') - line('w0') diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 729df28..d85bfcd 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -139,17 +139,19 @@ function! FugitiveHead(...) abort return fugitive#repo(dir).head(a:0 ? a:1 : 0) endfunction -function! FugitivePath(...) abort - let file = fnamemodify(a:0 ? a:1 : @%, ':p') - if file =~? '^fugitive:' - return fugitive#Path(file) - else +function! FugitiveReal(...) abort + let file = a:0 ? a:1 : @% + if file =~? '^fugitive:' || a:0 > 1 + return call('fugitive#Real', [file] + a:000[1:-1]) + elseif file =~# '^/\|^\a\+:' return file + else + return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??')) endif endfunction -function! FugitiveReal(...) abort - return call('FugitivePath', a:000) +function! FugitivePath(...) abort + return call(a:0 > 1 ? 'fugitive#Path' : 'FugitiveReal', a:000) endfunction function! FugitiveGenerate(...) abort