git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* request: add git grep -o option
@ 2019-10-30 19:58 Joe Perches
  2019-10-30 20:17 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2019-10-30 19:58 UTC (permalink / raw)
  To: git

Instead of duplicating a grep pattern with grep -oh after
git grep like
this:

$ git grep -P '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?' -- '*.[ch]' | \
  grep -P -oh '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?'

it could be useful to have git grep have the same '-o' option 
as gnu grep.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: request: add git grep -o option
  2019-10-30 19:58 request: add git grep -o option Joe Perches
@ 2019-10-30 20:17 ` Jeff King
  2019-10-30 20:27   ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2019-10-30 20:17 UTC (permalink / raw)
  To: Joe Perches; +Cc: git, Taylor Blau

On Wed, Oct 30, 2019 at 12:58:59PM -0700, Joe Perches wrote:

> Instead of duplicating a grep pattern with grep -oh after
> git grep like
> this:
> 
> $ git grep -P '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?' -- '*.[ch]' | \
>   grep -P -oh '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?'
> 
> it could be useful to have git grep have the same '-o' option 
> as gnu grep.

Doesn't it already?

  $ git grep -P -oh '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?'
  for_each
  for_each
  for_each_abbrev
  for_each_builtin
  for_each_string_list_item
  for_each_ut
  [etc...]

It was new in Git v2.19.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: request: add git grep -o option
  2019-10-30 20:17 ` Jeff King
@ 2019-10-30 20:27   ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2019-10-30 20:27 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Taylor Blau

On Wed, 2019-10-30 at 16:17 -0400, Jeff King wrote:
> On Wed, Oct 30, 2019 at 12:58:59PM -0700, Joe Perches wrote:
> 
> > Instead of duplicating a grep pattern with grep -oh after
> > git grep like
> > this:
> > 
> > $ git grep -P '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?' -- '*.[ch]' | \
> >   grep -P -oh '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?'
> > 
> > it could be useful to have git grep have the same '-o' option 
> > as gnu grep.
> 
> Doesn't it already?
> 
>   $ git grep -P -oh '(?:[a-z0-9_]+_)?for_each(?:_[a-z0-9_]+)?'
>   for_each
>   for_each
>   for_each_abbrev
>   for_each_builtin
>   for_each_string_list_item
>   for_each_ut
>   [etc...]
> 
> It was new in Git v2.19.

OK, nice.  I never actually tried it and I have 2.24.
My docs need updating as that option is not mentioned.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-30 20:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 19:58 request: add git grep -o option Joe Perches
2019-10-30 20:17 ` Jeff King
2019-10-30 20:27   ` Joe Perches

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).