[PATCH v3 0/5] builtin/config: bug fixes for "get" subcommand with "--type=color"
From: Patrick Steinhardt <hidden>
Date: 2025-09-18 06:14:27
Hi,
this small patch series contains two bug fixes for `git config get
--type=color`:
- We restore the behaviour where we can now parse colors without a
config key.
- We stop spawning the pager when the user requests to print ANSI
color escape sequences.
Furthermore, the patch series does some lighter refactorings of t1300.
That test file still has its fair share of issues, but at least it looks
a bit less dirty now.
Changes in v2:
- Improve commit messages.
- Use "\EOF" and "-EOF" in more cases.
- Move a style fixup from the first commit into the second commit.
- Link to v1: https://lore.kernel.org/r/20250911-pks-config-color-v1-0-3a7c79df65b1@pks.im (local)
Changes in v3:
- Provide additional context as part of the commit message for the
commit that stops setting up the pager with `--type=color`.
- Link to v2: https://lore.kernel.org/r/20250915-pks-config-color-v2-0-e4290bd8d13c@pks.im (local)
Thanks!
Patrick
---
Patrick Steinhardt (5):
t1300: write test expectations in the test's body
t1300: small style fixups
builtin/config: do not die in `get_color()`
builtin/config: special-case retrieving colors without a key
builtin/config: do not spawn pager when printing color codes
builtin/config.c | 20 +++-
t/t1300-config.sh | 349 +++++++++++++++++++++++++++---------------------------
2 files changed, 187 insertions(+), 182 deletions(-)
Range-diff versus v2:
1: e61278d7c5 = 1: fdd1711881 t1300: write test expectations in the test's body
2: e6f1ea5283 = 2: 8e1e05d9e1 t1300: small style fixups
3: 6f8257aeb4 = 3: 1ef6272e64 builtin/config: do not die in `get_color()`
4: 27a8ab34b0 = 4: 5dcf8c6656 builtin/config: special-case retrieving colors without a key
5: 259600c32a ! 5: 05d5022c1b builtin/config: do not spawn pager when printing color codes
@@ Commit message
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.
+ may be written to the pager instead of directly to the terminal. This
+ behaviour is problematic for two reasons:
- Fix this by disabling the pager in case the user is asking us to print
- color sequences.
+ - 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 [off-list ref]
---
base-commit: ab427cd991100e94792fce124b0934135abdea4b
change-id: 20250911-pks-config-color-e5b8a213e895