summaryrefslogtreecommitdiff
path: root/color.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-07 15:33:09 -0400
committerJunio C Hamano <gitster@pobox.com>2014-10-14 11:01:21 -0700
commitf6c5a2968c103621adf6928a29e4895361eaa23b (patch)
tree60259098fe84c3a71ad16aea43d2dbfb38dd0ee3 /color.h
parent8852117a603c5ed5131233a80453db37c0958871 (diff)
downloadgit-f6c5a2968c103621adf6928a29e4895361eaa23b.tar.gz
color_parse: do not mention variable name in error messagejn/parse-config-slot
Originally the color-parsing function was used only for config variables. It made sense to pass the variable name so that the die() message could be something like: $ git -c color.branch.plain=bogus branch fatal: bad color value 'bogus' for variable 'color.branch.plain' These days we call it in other contexts, and the resulting error messages are a little confusing: $ git log --pretty='%C(bogus)' fatal: bad color value 'bogus' for variable '--pretty format' $ git config --get-color foo.bar bogus fatal: bad color value 'bogus' for variable 'command line' This patch teaches color_parse to complain only about the value, and then return an error code. Config callers can then propagate that up to the config parser, which mentions the variable name. Other callers can provide a custom message. After this patch these three cases now look like: $ git -c color.branch.plain=bogus branch error: invalid color value: bogus fatal: unable to parse 'color.branch.plain' from command-line config $ git log --pretty='%C(bogus)' error: invalid color value: bogus fatal: unable to parse --pretty format $ git config --get-color foo.bar bogus error: invalid color value: bogus fatal: unable to parse default color value Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'color.h')
-rw-r--r--color.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/color.h b/color.h
index 9a8495bb7f..f5beab1ed7 100644
--- a/color.h
+++ b/color.h
@@ -77,8 +77,8 @@ int git_color_default_config(const char *var, const char *value, void *cb);
int git_config_colorbool(const char *var, const char *value);
int want_color(int var);
-void color_parse(const char *value, const char *var, char *dst);
-void color_parse_mem(const char *value, int len, const char *var, char *dst);
+int color_parse(const char *value, char *dst);
+int color_parse_mem(const char *value, int len, char *dst);
__attribute__((format (printf, 3, 4)))
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))