Try to use relative path for :Ggrep

References https://github.com/tpope/vim-fugitive/issues/1439
This commit is contained in:
Tim Pope
2020-01-21 15:27:59 -05:00
parent 21ed533001
commit 71038e83f1

View File

@@ -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)')