With a pager, like less, git grep already able to pass parameters to the specified pager:
-e
The next parameter is the template.
This option should be used for patterns starting with - and should be used in scripts that pass user input to grep.
Running git 2.0.1 (June 25, 2014), which also works with case insensitive git grep .
See commit f7febbe from Johannes Schindelin ( dscho ) :
git grep -O -i : if the pager is " less ", go to the option " -I "
When <command> turns out to be the magic string " less ", today
git grep -O<command> -e<pattern>
helps +/<pattern> skip less, so you can navigate through the results in the file using the n and shift + n keys.
Alas, this is not case-insensitive,
i.e.
git grep -i -O<command> -e<pattern>
In this case, we must go --IGNORE-CASE to " less " so that n and shift + n can move between the results, ignoring case in the pattern.
The original patch came from msysgit and was used by " -I ", but this was not due to lack of support for " -I ", but simply overlooked that it should work even if the template contains uppercase letters.
source share