mirror of
https://github.com/git/git
synced 2024-10-02 14:45:21 +00:00
"color.diff = true" is not "always" anymore.
Too many people got burned by setting color.diff and color.status to true when they really should have set it to "auto". This makes only "always" to do the unconditional colorization, and change the meaning of "true" to the same as "auto": colorize only when we are talking to a terminal. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d25430c5f8
commit
57f2b8424a
32
color.c
32
color.c
|
@ -118,21 +118,27 @@ void color_parse(const char *value, const char *var, char *dst)
|
||||||
|
|
||||||
int git_config_colorbool(const char *var, const char *value)
|
int git_config_colorbool(const char *var, const char *value)
|
||||||
{
|
{
|
||||||
if (!value)
|
if (value) {
|
||||||
return 1;
|
if (!strcasecmp(value, "never"))
|
||||||
if (!strcasecmp(value, "auto")) {
|
return 0;
|
||||||
if (isatty(1) || (pager_in_use && pager_use_color)) {
|
if (!strcasecmp(value, "always"))
|
||||||
char *term = getenv("TERM");
|
return 1;
|
||||||
if (term && strcmp(term, "dumb"))
|
if (!strcasecmp(value, "auto"))
|
||||||
return 1;
|
goto auto_color;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
if (!strcasecmp(value, "never"))
|
|
||||||
|
/* Missing or explicit false to turn off colorization */
|
||||||
|
if (!git_config_bool(var, value))
|
||||||
return 0;
|
return 0;
|
||||||
if (!strcasecmp(value, "always"))
|
|
||||||
return 1;
|
/* any normal truth value defaults to 'auto' */
|
||||||
return git_config_bool(var, value);
|
auto_color:
|
||||||
|
if (isatty(1) || (pager_in_use && pager_use_color)) {
|
||||||
|
char *term = getenv("TERM");
|
||||||
|
if (term && strcmp(term, "dumb"))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
|
static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
|
||||||
|
|
Loading…
Reference in a new issue