Am 21.10.2014 um 07:56 schrieb Zoltan Klinger:
When git grep is run with combined patterns such as '-e p1 --and -e p2'
and surrounding context lines are requested, the output contains
incorrectly highlighted matches.

Consider the following output (highlighted matches are surrounded by '*'
characters):
     $ cat testfile
     foo a
     foo b
     foo bar
     baz bar foo
     bar x
     bar y
     $ git grep -n -C2 -e foo --and -e bar testfile
     testfile-1-*foo* a
     testfile-2-*foo* b
     testfile:3:*foo* *bar*
     testfile:4:baz *bar* *foo*
     testfile-5-*bar* x
     testfile-6-*bar* y

Lines 1, 2, 5 and 6 do not match the combined patterns, they only
contain incorrectly highlighted 'false positives'.

The old code highlights all search terms, anywhere. I wouldn't call the ones in the context lines false positives. The user might be interested in those occurrences as well (I know I am ;).

GNU grep allows coloring to be configured in much greater detail with its GREP_COLORS variable. I didn't think that level of tuning is desirable until now. What your patch does is equivalent to change the default of "ms=01;31:mc=01;31" (color matching string in selected lines and context lines) to "ms=01;31:mc=" (color matching string in selected lines).

The difference is only visible with -v or git grep's --not and --and.

So, if you really don't want matching string in context lines to be colored, perhaps it's time to add a color.grep.contextmatch for matching text in context lines?

René

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to