"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>
Junio C Hamano committed
Nov 26, 2007 at 14:30 UTC
57f2b8424ade734550731392e90b8f738d478e02
1 file changed
+19
-13
color.c
+19
-13
@@ -118,21 +118,27 @@ bad:
118
119
int git_config_colorbool(const char *var, const char *value)
120
{
121
- if (!value)
122
- return 1;
123
- if (!strcasecmp(value, "auto")) {
124
- if (isatty(1) || (pager_in_use && pager_use_color)) {
125
- char *term = getenv("TERM");
126
- if (term && strcmp(term, "dumb"))
127
- return 1;
128
- }
129
- return 0;
121
+ if (value) {
122
+ if (!strcasecmp(value, "never"))
123
+ return 0;
124
+ if (!strcasecmp(value, "always"))
125
+ return 1;
126
+ if (!strcasecmp(value, "auto"))
127
+ goto auto_color;
128
}
131
- if (!strcasecmp(value, "never"))
129
+
130
+ /* Missing or explicit false to turn off colorization */
131
+ if (!git_config_bool(var, value))
132
return 0;
133
- if (!strcasecmp(value, "always"))
134
- return 1;
135
- return git_config_bool(var, value);
133
+
134
+ /* any normal truth value defaults to 'auto' */
135
+ auto_color:
136
+ if (isatty(1) || (pager_in_use && pager_use_color)) {
137
+ char *term = getenv("TERM");
138
+ if (term && strcmp(term, "dumb"))
139
+ return 1;
140
+ }
141
+ return 0;
142
}
143
144
static int color_vfprintf(FILE *fp, const char *color, const char *fmt,