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

git diff-index ignores color config

From
EPElias Persson <delreich@takeit.se>
Date
Apr 26, 2011, 15:04 UTC
Message-ID
<1303830261.3387.21.camel@dhcp-141.kontor.deklomp.se>
Having color.ui (and/or color.diff) set to auto, doing
   git diff-index --check <some refspec>

on a set with e.g. trailing whitespace does not produce colored output.

If providing the option on the command line, e.g.
   git diff-index --check --color=auto <some refspec>

output _is_ colored, so obviously not an issue with tty detection. Doesn't work when configured to 'true' either.

Documentation indicates that the config option is considered (see under --no-color), so to me it seems like there's a bug here, somewhere.

Most likely way of coming across this issue would be turning on the shipped pre-commit hook sample, at least that's how I found it. It ends (and does most of its work) with

    exec git diff-index --check --cached $against --
where $against is normally HEAD.

git --version: 1.7.4.4 uname -srio: Linux 2.6.35.12-88.fc14.i686 i386 GNU/Linux

// Delreich
Next: Junio C Hamano
Message 1 of 9 in “git diff-index ignores color config”
  1. Elias PerssonApr 26, 2011
  2. Junio C HamanoApr 26, 2011
  3. Elias PerssonApr 27, 2011
  4. config.txt,diff-options.txt: porcelain vs. plumbing for color.diffMichael J Gruber, Apr 27, 2011
  5. Jonathan NiederApr 27, 2011
  6. Junio C HamanoApr 27, 2011
  7. Junio C HamanoApr 27, 2011
  8. Jonathan NiederApr 27, 2011
  9. Michael J GruberApr 28, 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.