Merge branch 'tb/config-default'
"git config --get" learned the "--default" option, to help the calling script. Building on top of the tb/config-type topic, the "git config" learns "--type=color" type. Taken together, you can do things like "git config --get foo.color --default blue" and get the ANSI color sequence for the color given to foo.color variable, or "blue" if the variable does not exist. * tb/config-default: builtin/config: introduce `color` type specifier config.c: introduce 'git_config_color' to parse ANSI colors builtin/config: introduce `--default`
This commit is contained in:
10
config.c
10
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;
|
||||
@ -1067,6 +1068,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 */
|
||||
|
||||
Reference in New Issue
Block a user