DWIM for :(top)/absolute/path

This commit is contained in:
Tim Pope 2019-07-08 08:33:39 -04:00
parent 6b02026cf9
commit 668a615559

View File

@ -765,6 +765,7 @@ function! fugitive#Find(object, ...) abort
let rev = s:Slash(a:object) let rev = s:Slash(a:object)
let tree = s:Tree(dir) let tree = s:Tree(dir)
let base = len(tree) ? tree : 'fugitive://' . dir . '//0' let base = len(tree) ? tree : 'fugitive://' . dir . '//0'
let g:rev = rev
if rev ==# '.git' if rev ==# '.git'
let f = len(tree) ? tree . '/.git' : dir let f = len(tree) ? tree . '/.git' : dir
elseif rev =~# '^\.git/' elseif rev =~# '^\.git/'
@ -810,7 +811,12 @@ function! fugitive#Find(object, ...) abort
let f = fugitive#Find('.git/index', dir) let f = fugitive#Find('.git/index', dir)
endif endif
elseif rev =~# '^:(\%(top\|top,literal\|literal,top\|literal\))' elseif rev =~# '^:(\%(top\|top,literal\|literal,top\|literal\))'
let f = base . '/' . matchstr(rev, ')\zs.*') let f = matchstr(rev, ')\zs.*')
if f=~# '^\.\.\=\%(/\|$\)'
let f = simplify(getcwd() . '/' . f)
elseif f !~# '^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '')
let f = base . '/' . f
endif
elseif rev =~# '^:/\@!' elseif rev =~# '^:/\@!'
let f = 'fugitive://' . dir . '//0/' . rev[1:-1] let f = 'fugitive://' . dir . '//0/' . rev[1:-1]
else else