diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-10-27 12:54:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-10-27 12:54:05 -0700 |
commit | 2e50bf575fbaaf3b0410ae9af0c1ab6af691aa9c (patch) | |
tree | 540aae001774c52ace3c59477a3cb313b6476bad /grep.c | |
parent | d5a7410d22075ecf9f2597d2516bb9914cd55049 (diff) | |
download | git-zk/grep-color-words.tar.gz |
Revert "grep: fix match highlighting for combined patterns with context lines"zk/grep-color-words
This reverts commit d5a7410d22075ecf9f2597d2516bb9914cd55049.
It turns out that showing partial matches on the lines that are not
matching ones is a feature, not a bug, modelling after ms/mc
specifiers in GNU grep's environment variables GREP_COLORS.
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 42 |
1 files changed, 20 insertions, 22 deletions
@@ -1112,33 +1112,31 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, output_sep(opt, sign); } if (opt->color) { - if (sign == ':') { - /* paint the hits on matched lines */ - regmatch_t match; - enum grep_context ctx = GREP_CONTEXT_BODY; - int ch = *eol; - int eflags = 0; + regmatch_t match; + enum grep_context ctx = GREP_CONTEXT_BODY; + int ch = *eol; + int eflags = 0; + if (sign == ':') line_color = opt->color_selected; - *eol = '\0'; - while (next_match(opt, bol, eol, ctx, &match, eflags)) { - if (match.rm_so == match.rm_eo) - break; - - output_color(opt, bol, match.rm_so, line_color); - output_color(opt, bol + match.rm_so, - match.rm_eo - match.rm_so, - opt->color_match); - bol += match.rm_eo; - rest -= match.rm_eo; - eflags = REG_NOTBOL; - } - *eol = ch; - } else if (sign == '-') { + else if (sign == '-') line_color = opt->color_context; - } else if (sign == '=') { + else if (sign == '=') line_color = opt->color_function; + *eol = '\0'; + while (next_match(opt, bol, eol, ctx, &match, eflags)) { + if (match.rm_so == match.rm_eo) + break; + + output_color(opt, bol, match.rm_so, line_color); + output_color(opt, bol + match.rm_so, + match.rm_eo - match.rm_so, + opt->color_match); + bol += match.rm_eo; + rest -= match.rm_eo; + eflags = REG_NOTBOL; } + *eol = ch; } output_color(opt, bol, rest, line_color); opt->output(opt, "\n", 1); |