commit 71038e83f138e9cc4e8499900756ead015aaa588 (tree)
parent 21ed53300186ae7cdfae8714fafe822097039bd7
Author: Tim Pope <code@tpope.net>
Date: Tue, 21 Jan 2020 15:27:59 -0500
Try to use relative path for :Ggrep
References https://github.com/tpope/vim-fugitive/issues/1439
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -4095,7 +4095,6 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort
endif
let tree = s:Tree(dir)
let args = a:args
- let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ? 'fugitive://' . dir . '//0/' : tree . '/')
let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match')
let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args
if listnr > 0
@@ -4108,6 +4107,9 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort
let tempfile = tempname()
let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive'
silent exe s:DoAutocmd('QuickFixCmdPre ' . event)
+ let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ?
+ \ 'fugitive://' . dir . '//0/' :
+ \ s:cpath(getcwd(), tree) ? '' : tree . '/')
exe '!' . escape(s:UserCommand(dir, cmd + args), '%#!')
\ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile))
let list = map(readfile(tempfile), 's:GrepParseLine(prefix, name_only, dir, v:val)')