Re: [PATCH 2/2] builtin/grep.c: teach '-o', '--only-matching' to 'git-grep'
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 5, 2018, 07:36 UTC
- Message-ID
- <CAPig+cSRJWW4-7vj6wK8aOfNB20bqUCSOOySjdPci1r5Vb83Uw@mail.gmail.com>
- In-Reply-To
- <c8b527c5de3b0e5422d2c1afb91d454d1e46fff4.1525492696.git.me@ttaylorr.com>
On Sat, May 5, 2018 at 12:03 AM, Taylor Blau <me@ttaylorr.com> wrote:
Show 13 quoted lines
> Teach GNU grep(1)'s '-o' ('--only-matching') to 'git-grep'. This option
> prints only the matching components of each line. It writes multiple
> lines if more than one match exists on a given line.
>
> For example:
>
> $ git grep -on --column --heading git -- README.md | head -3
> README.md
> 15:56:git
> 18:20:git
>
> By using show_line_header(), 'git grep --only-matching' correctly
> respects the '--header' option:What is the '--header' option? I don't see it used in any example.
Show 5 quoted lines
> $ git grep -on --column --heading git -- README.md | head -4 > README.md > 15:56:git > 18:20:git > 19:16:git
How does this example differ from the earlier example (other than showing 4 lines of output rather than 3)?
> Signed-off-by: Taylor Blau <me@ttaylorr.com>