Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-28 Thread Jeff King
On Mon, Jun 25, 2018 at 04:26:00PM -0500, Taylor Blau wrote: > For instance, a line containing the following (taken from README.md:27): > > (`man gitcvs-migration` or `git help cvs-migration` if git is > > Is printed as follows: > > $ git grep -no -e git -- README.md | grep ":27" >

Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-27 Thread Taylor Blau
On Wed, Jun 27, 2018 at 02:11:13PM -0700, Junio C Hamano wrote: > Taylor Blau writes: > > >> 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 > >

Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-27 Thread Junio C Hamano
Taylor Blau writes: >> 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

Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-27 Thread Taylor Blau
On Wed, Jun 27, 2018 at 09:40:10AM -0700, Junio C Hamano wrote: > Taylor Blau writes: > > > - if (sign == ':') > > - match_color = opt->color_match_selected; > > - else > > - match_color = opt->color_match_context; > > - if (sign

Re: [PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-27 Thread Junio C Hamano
Taylor Blau writes: > - if (sign == ':') > - match_color = opt->color_match_selected; > - else > - match_color = opt->color_match_context; > - if (sign == ':') > - line_color = opt->color_selected; >

[PATCH 2/2] grep.c: teach 'git grep --only-matching'

2018-06-25 Thread Taylor Blau
Teach 'git grep --only-matching', a new option to only print the matching part(s) of a line. For instance, a line containing the following (taken from README.md:27): (`man gitcvs-migration` or `git help cvs-migration` if git is Is printed as follows: $ git grep -no -e git -- README.md |