grep: fix colouring of matches with zero length
[gitweb.git] / grep.c
diff --git a/grep.c b/grep.c
index cc6d5b04c15b670c55bdb9e2089e0b71f72453cc..7bf4a60ac7704e16abe9054296c1e0e77c984344 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -500,6 +500,8 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
 
                *eol = '\0';
                while (next_match(opt, bol, eol, ctx, &match, eflags)) {
+                       if (match.rm_so == match.rm_eo)
+                               break;
                        printf("%.*s%s%.*s%s",
                               (int)match.rm_so, bol,
                               opt->color_match,