vim-easygrep icon indicating copy to clipboard operation
vim-easygrep copied to clipboard

Git expects '--' before files list

Open noscript opened this issue 9 years ago • 0 comments

I use git mode with files filtering:

set grepprg=git\ grep\ -n\ -I
let g:EasyGrepCommand = 1
let g:EasyGrepMode = 2

When enabling logging I see that the expression is not correct:

grep! -i "WORD" *.c *.h *.cpp *.hpp *.cxx *.hxx *.cc *.hh *.c++ *.inl *.inc

Thus the error:

|| fatal: ambiguous argument '*.c': unknown revision or path not in the working tree.
|| Use '--' to separate paths from revisions, like this:
|| 'git <command> [<revision>...] -- [<file>...]'

The files files list passed to git have to be separated from the rest of options with -- ( source: https://git-scm.com/docs/git-grep).

My workaround is

--- a/plugin/EasyGrep.vim
+++ b/plugin/EasyGrep.vim
@@ -2644,7 +2644,7 @@ function! s:GetGrepCommandLine(pattern, add, wholeword, count, escapeArgs, filte
     let filesToGrep = join(fileTargetList, ' ')

     let win = g:EasyGrepWindow != 0 ? "l" : ""
-    let grepCommand = a:count.win.com.a:add.bang." ".opts.pattern.aux_pattern_postfix." ".filesToGrep
+    let grepCommand = a:count.win.com.a:add.bang." ".opts.pattern.aux_pattern_postfix." -- ".filesToGrep

     return grepCommand
 endfunction

but I'm sure you know a better way to fix this.

noscript avatar Aug 19 '16 13:08 noscript