commit 668a6155592e582072a85adf07ba84742570fe4e (tree)
parent 6b02026cf965134b88a582d744234f3513501d61
Author: Tim Pope <code@tpope.net>
Date: Mon, 8 Jul 2019 08:33:39 -0400
DWIM for :(top)/absolute/path
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -765,6 +765,7 @@ function! fugitive#Find(object, ...) abort
let rev = s:Slash(a:object)
let tree = s:Tree(dir)
let base = len(tree) ? tree : 'fugitive://' . dir . '//0'
+ let g:rev = rev
if rev ==# '.git'
let f = len(tree) ? tree . '/.git' : dir
elseif rev =~# '^\.git/'
@@ -810,7 +811,12 @@ function! fugitive#Find(object, ...) abort
let f = fugitive#Find('.git/index', dir)
endif
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 =~# '^:/\@!'
let f = 'fugitive://' . dir . '//0/' . rev[1:-1]
else