Subject: Re: [PATCH v2 5/5] builtin/config: do not spawn pager when printing color codes

From: Junio C Hamano <[email-masked]>
Date: Mon, 15 Sep 2025 10:28:23 -0700

Patrick Steinhardt <[email-masked]> writes:

> With `git config get --type=color` the user asks us to parse a specific
> configuration key and turn the value into an ANSI color escape sequence.
> The printed string can then for example be used as part of shell scripts
> to reuse the same colors as Git.
>
> Right now though we set up the auto-pager, which means that the string
> may instead be written to the pager command. This is of course quite
> nonsensical; there shouldn't be any use case where the color code should
> end up in the pager instead of in the TTY.
>
> Fix this by disabling the pager in case the user is asking us to print
> color sequences.

I am of two minds.  Part of me obviously agrees that it is more
straight forward with this change.  But it may 

An interactive user experimenting while writing their own script
might say something like

 $ git config --type=color --default="reverse red" n.n

If the command emitted directly to the terminal, then everything
they type from then on will be bloody red, but the pager protects
them from such an accident.  Instead, they are forced to say

 $ C=$(git config get --type=color --default="reverse red" n.n)
 $ R=$(git config get --type=color --default="reset" n.n)
 $ echo "So$C Bloody ${R}Red"

but these are likely what they would be writing in their script
anyway, so...