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

Re: [PATCH 4/5] grep: Colorize filename, line number, and separator

From
Mark Lodato <lodatom@gmail.com>
Date
Mar 3, 2010, 04:26 UTC
Message-ID
<ca433831003022026pbc172d6ocb5ff2aefe29f462@mail.gmail.com>
In-Reply-To
<4b8cb38b.870fcc0a.7ebc.1a83@mx.google.com>
On Tue, Mar 2, 2010 at 1:43 AM, Michael Witten <mfwitten@gmail.com> wrote:
Show 11 quoted lines
>> By the way, the default should be 'always', not
>> 'auto', to be consistent with GNU tools, and to be backwards
>> compatible with the old --color behavior.
>
> Well, I've got:
>
>    GNU grep 2.5.4
>
> and the default for a plain `--color' seems to be `auto', whereby
> colorization is turned on when stdout is attached to a tty capable
> of color, but turned off otherwise:

Sorry, that was my mistake about GNU grep. However, GNU ls (coreutils 7.4) defaults to 'always'. So, GNU tools are not consistent in this regard. Furthermore, the current behavior of all git tools is to make --color turn on color always, so I imagine you would have to make an extremely compelling argument to break backwards compatibility. I'll add that this behavior makes the most sense, since most folks who use color have done `git config color.ui auto'. This is why no one have created this patch until now. The [=<when>] part is nice, but the git config infrastructure usually obviates the need for --color=auto.

Show 5 quoted lines
> Firstly, note that GNU understands a wide set of option arguments:
>
>    1: always , yes , force
>    0: never  , no  , none
>    2: auto   , tty , if-tty

I guess this is okay, but I don't see a need for it. If we allow these other synonyms, then we'll have to support them forever. I say just stick with always/never/auto for now, and we could add the others later if there's a big demand.

> In my opinion, Git grep should follow GNU grep's conventions, not
> only to be consistent, but also because they are better.

It is more important to be consistent with the other git tools, so that is why --color is a synonym for --color=always.

Previous: Michael WittenNext: Miles Bader
Message 18 of 25 in “color enhancements, particularly for grep”
  1. 0/5 color enhancements, particularly for grepMark Lodato, Feb 27, 2010
  2. 1/5 Allow explicit ANSI codes for colorsMark Lodato, Feb 27, 2010
  3. Jeff KingFeb 27, 2010
  4. Mark LodatoFeb 27, 2010
  5. Junio C HamanoFeb 27, 2010
  6. color: allow multiple attributesJunio C Hamano, Feb 28, 2010
  7. Jeff KingFeb 28, 2010
  8. Junio C HamanoFeb 28, 2010
  9. Jeff KingFeb 28, 2010
  10. 2/5 Add GIT_COLOR_BOLD_* and GIT_COLOR_BG_*Mark Lodato, Feb 27, 2010
  11. 3/5 Remove reference to GREP_COLORS from documentationMark Lodato, Feb 27, 2010
  12. 4/5 grep: Colorize filename, line number, and separatorMark Lodato, Feb 27, 2010
  13. René ScharfeFeb 27, 2010
  14. Mark LodatoFeb 28, 2010
  15. Michael WittenFeb 28, 2010
  16. Mark LodatoMar 2, 2010
  17. Michael WittenMar 2, 2010
  18. Mark LodatoMar 3, 2010
  19. Miles BaderMar 3, 2010
  20. René ScharfeFeb 27, 2010
  21. Junio C HamanoFeb 27, 2010
  22. Mark LodatoFeb 28, 2010
  23. Junio C HamanoFeb 28, 2010
  24. Mark LodatoFeb 28, 2010
  25. 5/5 grep: Colorize selected, context, and function linesMark Lodato, Feb 27, 2010

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.