Thread (41 messages) 41 messages, 4 authors, 2018-04-10

Re: [PATCH 3/4] config.c: introduce 'git_config_color' to parse ANSI colors

From: Jeff King <hidden>
Date: 2018-03-06 06:53:59

On Mon, Mar 05, 2018 at 06:17:28PM -0800, Taylor Blau wrote:
In preparation for adding `--color` to the `git-config(1)` builtin,
let's introduce a color parsing utility, `git_config_color` in a similar
fashion to `git_config_<type>`.
Sounds good...
quoted hunk ↗ jump to hunk
@@ -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;
+}
Why do we take a pointer-to-pointer here? We don't allocate like
git_config_string() does, but instead fill in the existing buffer.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help