Preserve trailing slash in FugitiveReal()

This commit is contained in:
Tim Pope 2018-07-22 13:57:28 -04:00
parent d818ac93af
commit 1e7e707696
2 changed files with 18 additions and 14 deletions

View File

@ -520,19 +520,21 @@ function! s:DirRev(url) abort
return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')] return [dir, (commit =~# '^.$' ? ':' : '') . commit . substitute(file, '^/', ':', '')]
endfunction endfunction
function! fugitive#Path(url) abort function! fugitive#Real(url) abort
let [dir, commit, file] = s:DirCommitFile(a:url) let [dir, commit, file] = s:DirCommitFile(a:url)
if len(dir) if len(dir)
let tree = FugitiveTreeForGitDir(dir) let tree = FugitiveTreeForGitDir(dir)
return s:PlatformSlash((len(tree) ? tree : dir) . file) return s:PlatformSlash((len(tree) ? tree : dir) . file)
elseif a:url =~# '^[\\/]\|^\a:[\\/]' endif
return s:PlatformSlash(a:url) let url = fnamemodify(a:url, ':p' . (a:url =~# '[\/]$' ? '' : ':s?[\/]$??'))
if url =~# '^[\\/]\|^\a:[\\/]'
return s:PlatformSlash(url)
endif endif
return '' return ''
endfunction endfunction
function! fugitive#Real(url) abort function! fugitive#Path(url) abort
return fugitive#Path(a:url) return fugitive#Real(a:url)
endfunction endfunction
let s:trees = {} let s:trees = {}
@ -2329,7 +2331,7 @@ function! s:BlameCommit(cmd) abort
let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]') let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]')
let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ')
if path ==# '' if path ==# ''
let path = s:buffer(b:fugitive_blamed_bufnr).relative('') let path = fugitive#Path(bufname(b:fugitive_blamed_bufnr), '')
endif endif
execute cmd execute cmd
if search('^diff .* b/\M'.escape(path,'\').'$','W') 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 lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]')
let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ')
if path ==# '' if path ==# ''
let path = s:buffer(b:fugitive_blamed_bufnr).relative('') let path = fugitive#Path(bufname(b:fugitive_blamed_bufnr), '')
endif endif
let args = b:fugitive_blame_arguments let args = b:fugitive_blame_arguments
let offset = line('.') - line('w0') let offset = line('.') - line('w0')

View File

@ -139,17 +139,19 @@ function! FugitiveHead(...) abort
return fugitive#repo(dir).head(a:0 ? a:1 : 0) return fugitive#repo(dir).head(a:0 ? a:1 : 0)
endfunction endfunction
function! FugitivePath(...) abort function! FugitiveReal(...) abort
let file = fnamemodify(a:0 ? a:1 : @%, ':p') let file = a:0 ? a:1 : @%
if file =~? '^fugitive:' if file =~? '^fugitive:' || a:0 > 1
return fugitive#Path(file) return call('fugitive#Real', [file] + a:000[1:-1])
else elseif file =~# '^/\|^\a\+:'
return file return file
else
return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))
endif endif
endfunction endfunction
function! FugitiveReal(...) abort function! FugitivePath(...) abort
return call('FugitivePath', a:000) return call(a:0 > 1 ? 'fugitive#Path' : 'FugitiveReal', a:000)
endfunction endfunction
function! FugitiveGenerate(...) abort function! FugitiveGenerate(...) abort