git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] Some subcommands ignore color.diff and color.ui in --patch mode
@ 2025-08-20 11:05 Isaac Oscar Gariano
  2025-08-20 22:04 ` Jeff King
  0 siblings, 1 reply; 23+ messages in thread
From: Isaac Oscar Gariano @ 2025-08-20 11:05 UTC (permalink / raw)
  To: git@vger.kernel.org

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​

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-09-09  6:09 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 11:05 [BUG] Some subcommands ignore color.diff and color.ui in --patch mode Isaac Oscar Gariano
2025-08-20 22:04 ` Jeff King
2025-08-20 23:48   ` Isaac Oscar Gariano
2025-08-21  7:00     ` Jeff King
2025-08-21  7:07   ` [PATCH 0/4] oddities around add-interactive and color Jeff King
2025-08-21  7:15     ` [PATCH 1/4] stash: pass --no-color to diff-tree child processes Jeff King
2025-09-03  7:23       ` Patrick Steinhardt
2025-09-08 16:06         ` Jeff King
2025-08-21  7:19     ` [PATCH 2/4] add-interactive: respect color.diff for diff coloring Jeff King
2025-09-03  7:23       ` Patrick Steinhardt
2025-09-08 16:16         ` Jeff King
2025-09-09  6:06           ` Patrick Steinhardt
2025-08-21  7:22     ` [PATCH 3/4] add-interactive: manually fall back color config to color.ui Jeff King
2025-08-21 15:42       ` Junio C Hamano
2025-09-03  7:23       ` Patrick Steinhardt
2025-09-08 16:17         ` Jeff King
2025-08-21  7:22     ` [PATCH 4/4] contrib/diff-highlight: mention interactive.diffFilter Jeff King
2025-09-08 16:41     ` [PATCH v2 0/4] oddities around add-interactive and color Jeff King
2025-09-08 16:42       ` [PATCH v2 1/4] stash: pass --no-color to diff plumbing child processes Jeff King
2025-09-08 16:42       ` [PATCH v2 2/4] add-interactive: respect color.diff for diff coloring Jeff King
2025-09-08 16:42       ` [PATCH v2 3/4] add-interactive: manually fall back color config to color.ui Jeff King
2025-09-08 16:42       ` [PATCH v2 4/4] contrib/diff-highlight: mention interactive.diffFilter Jeff King
2025-09-09  6:09       ` [PATCH v2 0/4] oddities around add-interactive and color Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).