From 6d2f9acc0f6c2df2b75ac69aee9077d7ea4eb2b5 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Mon, 9 Apr 2018 17:18:28 -0700 Subject: config.c: introduce 'git_config_color' to parse ANSI colors In preparation for adding `--type=color` to the `git-config(1)` builtin, let's introduce a color parsing utility, `git_config_color` in a similar fashion to `git_config_`. Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- config.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index b0c20e6cb8..33366b52c7 100644 --- a/config.c +++ b/config.c @@ -16,6 +16,7 @@ #include "string-list.h" #include "utf8.h" #include "dir.h" +#include "color.h" struct config_source { struct config_source *prev; @@ -1000,6 +1001,15 @@ int git_config_expiry_date(timestamp_t *timestamp, const char *var, const char * return 0; } +int git_config_color(char *dest, const char *var, const char *value) +{ + if (!value) + return config_error_nonbool(var); + if (color_parse(value, dest) < 0) + return -1; + return 0; +} + static int git_default_core_config(const char *var, const char *value) { /* This needs a better name */ -- cgit v1.2.3