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

Re: [PATCH] No color diff when redirecting to file

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2011, 23:32 UTC
Message-ID
<7voc77mc1v.fsf@alter.siamese.dyndns.org>
In-Reply-To
<vpq39oj4jfz.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 22 quoted lines
> Johannes Sixt <j6t@kdbg.org> writes:
>
>> That said, I cannot reproduce. Perhaps your configuration says 
>> color.ui=always? If so, then this is expected behavior and not a bug, IMO.
>
> I think you're right.
>
> I tested this (without the patch):
>
> git diff
> => I get color, because I have color.ui = auto
>
> git diff | cat
> => I don't get color
>
> git diff --color=auto | cat
> => no color
>
> git diff --color=always | cat
> => colors, because I've asked
>
> this seems to be just the right behavior.

Overall I agree with the above observation, but the original poster says "redirecting into a _file_".

Another possibility is that the mysterious platform the original poster did not mention has a broken istty() that mistakes a file descriptor going to a file (instead of a pipe to another process) as connected to a tty.

Previous: Matthieu MoyNext: Sascha Peilicke
Message 4 of 7 in “No color diff when redirecting to file”
  1. No color diff when redirecting to fileSascha Peilicke, Jan 23, 2011
  2. Johannes SixtJan 23, 2011
  3. Matthieu MoyJan 23, 2011
  4. Junio C HamanoJan 23, 2011
  5. Sascha PeilickeJan 24, 2011
  6. Matthieu MoyJan 24, 2011
  7. Sascha PeilickeJan 24, 2011

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.