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

[BUG] Some subcommands ignore color.diff and color.ui in --patch mode

From
IGIsaac Oscar Gariano <isaacoscar@live.com.au>
Date
Aug 20, 2025, 11:05 UTC
Message-ID
<SYBP282MB296329544B33E3C16DD99FD28C33A@SYBP282MB2963.AUSP282.PROD.OUTLOOK.COM>

Bassically the colouring behaviour of the interactive --patch option to the various commands differ. I'll call "commit, add, and stash the "good commands" (as they behave as I expect), and stash push, stash save, checkout, reset, and restore the "bad commands" (which are bugged).

I assume you have git v2.50.1, a dirty working tree, and no colour related settings in any of the config files, and where $CMD is the name of any "bad command".
The following all print in colour (I expect no colour):
    git -c color.diff=never        $CMD --patch .
    git -c color.ui=never          $CMD --patch .
The folowing do not print anything in colour (I expect it to work the same as without the cat):
    git -c color.diff=always        $CMD --patch . | cat
    git -c color.ui=always          $CMD --patch . | cat
Now the documenation for color.interactive says:
    When set to always, always use colors for interactive prompts and displays (such as those used by "git-add --interactive" and
    "git-clean --interactive"). When false (or never), never. When set to true or auto, use colors only when the output is to the
    terminal. If unset, then the value of color.ui is used (auto by default).
Now the bad commands are respecting the setting of color.interactive corroectly (and the same as the good commands).
For example, this always prints a coloured prompt (but not a coloured diff)
    git -c color.interactive=always          $CMD --patch . | cat
But as mentioned above, "color.ui=always" will NOT print the prompt in color.
As for why I care, I was trying to pipe git restore through diff-highlight (this functionality should really be inbuilt into git diff)
A related issue, that is probably not a 'bug': all the --patch options ignore the diff config options (e.g. diff.wordRegex).
— Isaac Oscar Gariano​
Next: Jeff King
Message 1 of 23 in “[BUG] Some subcommands ignore color.diff and color.ui in --patch mode”
  1. Isaac Oscar GarianoAug 20, 2025
  2. Jeff KingAug 20, 2025
  3. Isaac Oscar GarianoAug 20, 2025
  4. Jeff KingAug 21, 2025
  5. 0/4 oddities around add-interactive and colorJeff King, Aug 21, 2025
  6. 1/4 stash: pass --no-color to diff-tree child processesJeff King, Aug 21, 2025
  7. Patrick SteinhardtSep 3, 2025
  8. Jeff KingSep 8, 2025
  9. 2/4 add-interactive: respect color.diff for diff coloringJeff King, Aug 21, 2025
  10. Patrick SteinhardtSep 3, 2025
  11. Jeff KingSep 8, 2025
  12. Patrick SteinhardtSep 9, 2025
  13. 3/4 add-interactive: manually fall back color config to color.uiJeff King, Aug 21, 2025
  14. Junio C HamanoAug 21, 2025
  15. Patrick SteinhardtSep 3, 2025
  16. Jeff KingSep 8, 2025
  17. 4/4 contrib/diff-highlight: mention interactive.diffFilterJeff King, Aug 21, 2025
  18. 0/4 oddities around add-interactive and colorJeff King, Sep 8, 2025
  19. 1/4 stash: pass --no-color to diff plumbing child processesJeff King, Sep 8, 2025
  20. 2/4 add-interactive: respect color.diff for diff coloringJeff King, Sep 8, 2025
  21. 3/4 add-interactive: manually fall back color config to color.uiJeff King, Sep 8, 2025
  22. 4/4 contrib/diff-highlight: mention interactive.diffFilterJeff King, Sep 8, 2025
  23. Patrick SteinhardtSep 9, 2025

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.