From 668a6155592e582072a85adf07ba84742570fe4e Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 8 Jul 2019 08:33:39 -0400 Subject: [PATCH] DWIM for :(top)/absolute/path --- autoload/fugitive.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 2ac0467..d5c082d 100644 --- 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