summaryrefslogtreecommitdiff
path: root/add-interactive.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-09-16 16:25:26 -0400
committerJunio C Hamano <gitster@pobox.com>2025-09-16 18:00:25 -0700
commitb978f7803400b9f0c54f5874b085064c44a6c372 (patch)
tree3e41aeb9c9bcb753fb8c6e506edaeb3d9cbd3f61 /add-interactive.c
parente9330ae4b820147c98e723399e9438c8bee60a80 (diff)
color: return bool from want_color()
The point of want_color() is to take in a git_colorbool enum value and collapse it down to a single true/false boolean, letting UNKNOWN fall back to the color.ui default and checking isatty() for AUTO. Let's make that more clear in the type system by returning a bool rather than an integer. This sadly still does not help us much with compiler warnings for using the two types interchangeably. But it helps make the intent more clear to a human reader. We still retain the idempotency of want_color(), because in C a bool true/false converts to 1/0 when converted to an integer, which corresponds to GIT_COLOR_ALWAYS and GIT_COLOR_NEVER. So you can store the bool in a git_colorbool and get the right result (something a few pieces of code still do, but which we'll clean up in further patches). Note that we rely on this same bool/int conversion for check_auto_color(). We cache its results in a tristate int with "-1" as "not yet set", but we can assign to it (and return it) with implicit conversions to/from bool. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
0 files changed, 0 insertions, 0 deletions