diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index d55cfdd..b489c1f 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1159,7 +1159,7 @@ function! fugitive#Object(...) abort endif endfunction -let s:var = '\%(%\|#<\=\d\+\|##\=\|\)' +let s:var = '\%(<\%(cword\|cWORD\|cexpr\|cfile\|sfile\|slnum\|afile\|abuf\|amatch' . (has('clientserver') ? '\|client' : '') . '\)>\|%\|#<\=\d\+\|##\=\)' let s:flag = '\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)' let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)' @@ -1195,27 +1195,43 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort let owner = s:Owner(buffer) return len(owner) ? owner : '@' elseif a:var ==# '' - let cfile = expand('') + let bufname = expand('') if v:version >= 704 && get(maparg('', 'c', 0, 1), 'expr') try - let cfile = eval(maparg('', 'c')) + let bufname = eval(maparg('', 'c')) + if bufname ==# "\\" + let bufname = expand('') + endif catch endtry endif - return cfile + elseif a:var =~# '^<' + let bufname = s:BufName(a:var) + else + let bufname = fugitive#Real(s:BufName(a:var)) endif let flags = a:flags - let file = s:DotRelative(fugitive#Real(s:BufName(a:var)), cwd) + let file = s:DotRelative(bufname, cwd) while len(flags) let flag = matchstr(flags, s:flag) let flags = strpart(flags, len(flag)) if flag ==# ':.' - let file = s:DotRelative(file, cwd) + let file = s:DotRelative(fugitive#Real(file), cwd) else let file = fnamemodify(file, flag) endif endwhile let file = s:Slash(file) + if file =~# '^fugitive://' + let [dir, commit, file_candidate] = s:DirCommitFile(file) + let tree = s:Tree(dir) + if len(tree) && len(file_candidate) + let file = (commit =~# '^.$' ? ':' : '') . commit . ':' . + \ s:DotRelative(tree . file_candidate) + elseif empty(file_candidate) && commit !~# '^.$' + let file = commit + endif + endif return (len(a:esc) ? shellescape(file) : file) endfunction diff --git a/doc/fugitive.txt b/doc/fugitive.txt index d5c6afe..402fd18 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -588,8 +588,9 @@ Makefile The file named Makefile in the work tree !:Makefile The file named Makefile in the commit owning the current file !3^2 The second parent of the commit owning buffer #3 .git/config The repo config file -: The |fugitive-summary| buffer. +: The |fugitive-summary| buffer - A temp file containing the last |:Git| invocation's output + The file or commit under the cursor STATUSLINE *fugitive-statusline*