git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: request: add git grep -o option

From
Joe Perches <joe@perches.com>
Date
Oct 30, 2019, 20:27 UTC
Message-ID
<d56bb5bcba50f1d9adf861b985a9646e7f65bdc9.camel@perches.com>
In-Reply-To
<20191030201757.GA29013@sigill.intra.peff.net>
On Wed, 2019-10-30 at 16:17 -0400, Jeff King wrote:
Show 24 quoted lines
> 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.

Previous: Jeff King
Message 3 of 3 in “request: add git grep -o option”
  1. Joe PerchesOct 30, 2019
  2. Jeff KingOct 30, 2019
  3. Joe PerchesOct 30, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.