grep: prefer builtin over external one when coloring results
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 16 Mar 2009 02:20:04 +0000 (13:20 +1100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Mar 2009 00:03:33 +0000 (17:03 -0700)
As far as I know, not all grep programs support coloring, so we should
rely on builtin grep. If you want external grep, set
color.grep.external to empty string.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-grep.c

index 9e7e766a496e44d3f5f266f24eb3430ae046235a..89489ddcf8edb85160036b0336ab4ce80c3cb6bc 100644 (file)
@@ -825,6 +825,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                }
        }
 
+       if (opt.color && !opt.color_external)
+               builtin_grep = 1;
        if (!opt.pattern_list)
                die("no pattern given.");
        if ((opt.regflags != REG_NEWLINE) && opt.fixed)