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

Re: FW: Git log --graph doesn't output color when redirected

From
Jeff King <peff@peff.net>
Date
Dec 13, 2012, 13:13 UTC
Message-ID
<20121213131329.GA5042@sigill.intra.peff.net>
In-Reply-To
<72BB37CB88C48F4B925365539F1EE46C18261403@icexch-m3.ic.ac.uk>
On Wed, Dec 12, 2012 at 05:35:17PM +0000, Srb, Michal wrote:
> Unlike --pretty-format, --graph doesn’t output colors when the git log output
> is redirected.

I do not think it has anything to do with --graph in particular, but rather that when colorization is set to the "auto" mode, it is enabled only when stdout is a tty. Diff coloring, for example, follows the same rules. If you are using --format="%C(red)" or similar placeholders, they are the odd duck by not respecting the auto-color mode.

> Is there a setting somewhere in config to change this?

Yes. If you use "--color" on the command line, that means "unconditionally use color". If you set color.ui (or any other color config option) to "always", then you will always get color (and you can disable it for a particular run with "--no-color"). Setting a color config option to "true" is the same as "auto", which gets you the auto mode.

-Peff
Previous: Srb, MichalNext: Srb, Michal
Message 2 of 18 in “FW: Git log --graph doesn't output color when redirected”
  1. Srb, MichalDec 12, 2012
  2. Jeff KingDec 13, 2012
  3. Srb, MichalDec 13, 2012
  4. Nguyen Thai Ngoc DuyDec 15, 2012
  5. Jeff KingDec 15, 2012
  6. Junio C HamanoDec 15, 2012
  7. log --format: teach %C(auto,black) to paint it black only on terminalsJunio C Hamano, Dec 17, 2012
  8. Nguyen Thai Ngoc DuyDec 17, 2012
  9. Jeff KingDec 17, 2012
  10. Junio C HamanoDec 17, 2012
  11. Jeff KingDec 17, 2012
  12. Junio C HamanoDec 17, 2012
  13. Jeff KingDec 17, 2012
  14. 1/2 t6006: clean up whitespaceJunio C Hamano, Dec 17, 2012
  15. Jeff KingDec 17, 2012
  16. 1/2 t6006: clean up whitespaceJeff King, Dec 17, 2012
  17. 2/2 log --format: teach %C(auto,black) to respect color configJeff King, Dec 17, 2012
  18. Jeff KingDec 17, 2012

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.