diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-26 23:30:28 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-29 02:33:17 +0100 |
commit | 57f2b8424ade734550731392e90b8f738d478e02 (patch) | |
tree | 7062a3004200e9d7982e45db90998031542f2755 /color.c | |
parent | Merge branch 'maint' (diff) | |
download | git-57f2b8424ade734550731392e90b8f738d478e02.tar.xz git-57f2b8424ade734550731392e90b8f738d478e02.zip |
"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>
Diffstat (limited to 'color.c')
-rw-r--r-- | color.c | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -118,21 +118,27 @@ bad: int git_config_colorbool(const char *var, const char *value) { - if (!value) - return 1; - if (!strcasecmp(value, "auto")) { - if (isatty(1) || (pager_in_use && pager_use_color)) { - char *term = getenv("TERM"); - if (term && strcmp(term, "dumb")) - return 1; - } - return 0; + if (value) { + if (!strcasecmp(value, "never")) + return 0; + if (!strcasecmp(value, "always")) + return 1; + if (!strcasecmp(value, "auto")) + goto auto_color; } - if (!strcasecmp(value, "never")) + + /* Missing or explicit false to turn off colorization */ + if (!git_config_bool(var, value)) return 0; - if (!strcasecmp(value, "always")) - return 1; - return git_config_bool(var, value); + + /* any normal truth value defaults to 'auto' */ + 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, |