From: Taylor Blau <me@ttaylorr.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Git List" <git@vger.kernel.org>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH 2/2] builtin/grep.c: teach '-o', '--only-matching' to 'git-grep'
Date: Mon, 7 May 2018 17:27:48 -0700 [thread overview]
Message-ID: <20180508002748.GB6763@syl.local> (raw)
In-Reply-To: <CAPig+cSRJWW4-7vj6wK8aOfNB20bqUCSOOySjdPci1r5Vb83Uw@mail.gmail.com>
On Sat, May 05, 2018 at 03:36:12AM -0400, Eric Sunshine wrote:
> On Sat, May 5, 2018 at 12:03 AM, Taylor Blau <me@ttaylorr.com> wrote:
> > 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.
I think '--header' is a typo for '--heading', which is used in the
following example.
> > $ 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)?
Ack. I clipped from my terminal what I meant to be the seocnd
example, and pasted it in for both examples. They are meant to be as
follows:
1. 'git grep' without heading, showing the full line prefix, and
2. 'git grep' with heading, showing the file heading with '--heading'.
The later has '| head -n4' on the end to include 3+1 lines (3 matches, 1
heading) whereas the former has '| head -n3' to include 3 lines (3
matches, no heading).
I have updated my patch locally to reflect this.
Thanks,
Taylor
next prev parent reply other threads:[~2018-05-08 0:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-05 4:03 [PATCH 0/2] builtin/grep.c: teach '-o', '--only-matching' Taylor Blau
2018-05-05 4:03 ` [PATCH 1/2] grep.c: extract show_line_header() Taylor Blau
2018-05-05 7:30 ` Eric Sunshine
2018-05-08 0:24 ` Taylor Blau
2018-05-05 4:03 ` [PATCH 2/2] builtin/grep.c: teach '-o', '--only-matching' to 'git-grep' Taylor Blau
2018-05-05 6:49 ` Ævar Arnfjörð Bjarmason
2018-05-08 17:25 ` Jeff King
2018-05-10 2:00 ` Taylor Blau
2018-05-10 6:40 ` Jeff King
2018-05-05 7:36 ` Eric Sunshine
2018-05-08 0:27 ` Taylor Blau [this message]
2018-05-12 3:21 ` [PATCH v2 0/2] builtin/grep.c: teach '-o', '--only-matching' Taylor Blau
2018-05-12 3:21 ` [PATCH v2 1/2] grep.c: extract show_line_header() Taylor Blau
2018-05-12 3:21 ` [PATCH v2 2/2] builtin/grep.c: teach '-o', '--only-matching' to 'git-grep' Taylor Blau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180508002748.GB6763@syl.local \
--to=me@ttaylorr.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).