From 295d949cfabc18fb588f269c77d1f8ff4a613686 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 21 Apr 2018 12:09:57 +0200 Subject: color: introduce support for colorizing stderr So far, we only ever asked whether stdout wants to be colorful. In the upcoming patches, we will want to make push errors more prominent, which are printed to stderr, though. So let's refactor the want_color() function into a want_color_fd() function (which expects to be called with fd == 1 or fd == 2 for stdout and stderr, respectively), and then define the macro `want_color()` to use the want_color_fd() function. And then also add a macro `want_color_stderr()`, for convenience and for documentation. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- color.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'color.h') diff --git a/color.h b/color.h index cd0bcedd08..5b744e1bc6 100644 --- a/color.h +++ b/color.h @@ -88,7 +88,9 @@ int git_config_colorbool(const char *var, const char *value); * Return a boolean whether to use color, where the argument 'var' is * one of GIT_COLOR_UNKNOWN, GIT_COLOR_NEVER, GIT_COLOR_ALWAYS, GIT_COLOR_AUTO. */ -int want_color(int var); +int want_color_fd(int fd, int var); +#define want_color(colorbool) want_color_fd(1, (colorbool)) +#define want_color_stderr(colorbool) want_color_fd(2, (colorbool)) /* * Translate a Git color from 'value' into a string that the terminal can -- cgit v1.2.3