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_<type>`. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
eeaa24b990
commit
6d2f9acc0f
10
config.c
10
config.c
@ -16,6 +16,7 @@
|
|||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
struct config_source {
|
struct config_source {
|
||||||
struct config_source *prev;
|
struct config_source *prev;
|
||||||
@ -1000,6 +1001,15 @@ int git_config_expiry_date(timestamp_t *timestamp, const char *var, const char *
|
|||||||
return 0;
|
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)
|
static int git_default_core_config(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
/* This needs a better name */
|
/* This needs a better name */
|
||||||
|
1
config.h
1
config.h
@ -59,6 +59,7 @@ extern int git_config_bool(const char *, const char *);
|
|||||||
extern int git_config_string(const char **, const char *, const char *);
|
extern int git_config_string(const char **, const char *, const char *);
|
||||||
extern int git_config_pathname(const char **, const char *, const char *);
|
extern int git_config_pathname(const char **, const char *, const char *);
|
||||||
extern int git_config_expiry_date(timestamp_t *, const char *, const char *);
|
extern int git_config_expiry_date(timestamp_t *, const char *, const char *);
|
||||||
|
extern int git_config_color(char *, const char *, const char *);
|
||||||
extern int git_config_set_in_file_gently(const char *, const char *, const char *);
|
extern int git_config_set_in_file_gently(const char *, const char *, const char *);
|
||||||
extern void git_config_set_in_file(const char *, const char *, const char *);
|
extern void git_config_set_in_file(const char *, const char *, const char *);
|
||||||
extern int git_config_set_gently(const char *, const char *);
|
extern int git_config_set_gently(const char *, const char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user