]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/config: do not spawn pager when printing color codes
authorPatrick Steinhardt <ps@pks.im>
Mon, 22 Sep 2025 13:06:22 +0000 (15:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Sep 2025 16:32:57 +0000 (09:32 -0700)
commite4dabf4fd62470f03b5aa3f1ad615cd7121cb5c5
tree45763f1faa8dd4fed17043e52453a47ffc765003
parent54b24b108055d9ba4850706a8ed8ee53edf08e37
builtin/config: do not spawn pager when printing color codes

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 be written to the pager instead of directly to the terminal. This
behaviour is problematic for two reasons:

  - Color codes are meant for direct terminal output; writing them into
    a pager does not seem like a sensible thing to do without additional
    text.

  - It is inconsistent with `git config --get-color`, which never uses a
    pager, despite the fact that we claim `git config get --type=color`
    to be a drop-in replacement in git-config(1).

Fix this by disabling the pager when outputting color sequences.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
t/t1300-config.sh