Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 27, 2018, 21:11 UTC
- Message-ID
- <xmqq6024djf2.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180627171657.GA26628@syl.attlocal.net>
Taylor Blau <me@ttaylorr.com> writes:
Show 19 quoted lines
>> Just initializing match_color where it is defined at the beginning of
>> show_line() should be sufficient, I think.
>
> I think that we could also use the following, and leave the `if
> (opt->color)` conditional where it is:
>
> diff --git a/grep.c b/grep.c
> index 48cca6723e..b985fb3ee0 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -1448,7 +1448,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
> const char *name, unsigned lno, ssize_t cno, char sign)
> {
> int rest = eol - bol;
> - const char *match_color, *line_color = NULL;
> + const char *match_color = NULL, *line_color = NULL;
>
> if (opt->file_break && opt->last_shown == 0) {
> if (opt->show_hunk_mark)You say "we could also", but the above is exactly what I suggested, so we seem to be on the same page, which is good ;-)