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

Re: [PATCH] git-grep: add --color to highlight matches

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 26, 2008, 11:29 UTC
Message-ID
<alpine.DEB.1.00.0805261227440.30431@racer>
In-Reply-To
<fcaeb9bf0805260407r6a1bea23v3861d3c43df01939@mail.gmail.com>
Hi,
On Mon, 26 May 2008, Nguyen Thai Ngoc Duy wrote:
Show 19 quoted lines
> On Mon, May 26, 2008 at 6:00 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>
> > On Mon, 26 May 2008, Nguyen Thai Ngoc Duy wrote:
> >
> >> On Mon, May 26, 2008 at 5:16 PM, Johannes Schindelin
> >> <Johannes.Schindelin@gmx.de> wrote:
> >> > Besides, it would be a kludge at best to work _twice_ to find out 
> >> > the search terms, once in the external grep, and a second time in 
> >> > the coloring code.  So I think it should not be done.
> >>
> >> I think if it's GNU grep, just passing it --color, it will grep and 
> >> colorize search terms in one turn.
> >
> > And what tells you that the called grep is GNU grep?
> 
> A newly added macro like HAS_GNU_GREP? Granted it won't work all the
> time. The user who set the macro should know what he is doing. This
> approach is IMHO fine as long as we don't allow color customization.

IMO this is just a kludge that is not even necessary, because the whole notion of relying on an external grep's colorization is crap.

The OP has a patch that adds colorization to Git's internal grep code. The user specifies "--color" with grep? Fine, then it's no external grep. Full stop.

Just like the original patch implements it. Nice, simple, and easy. What is so wrong with that?

Ciao, Dscho

Previous: Nguyen Thai Ngoc Duy
Message 10 of 10 in “git-grep: add --color to highlight matches”
  1. git-grep: add --color to highlight matchesNguyễn Thái Ngọc Duy, May 24, 2008
  2. Jakub NarebskiMay 24, 2008
  3. Nguyen Thai Ngoc DuyMay 24, 2008
  4. Jakub NarebskiMay 24, 2008
  5. Andreas EricssonMay 26, 2008
  6. Johannes SchindelinMay 26, 2008
  7. Nguyen Thai Ngoc DuyMay 26, 2008
  8. Johannes SchindelinMay 26, 2008
  9. Nguyen Thai Ngoc DuyMay 26, 2008
  10. Johannes SchindelinMay 26, 2008

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.