colored diff: diff.color = auto fix
Even if the standard output is connected to a tty, do not colorize the diff if we are talking to a dumb terminal when diff.color configuration variable is set to "auto". Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jul 7, 2006 at 17:48 UTC
a0c2089c1d48dc9969822126170d35c6e5aa141f
1 file changed
+8
-2
diff.c
+8
-2
@@ -110,8 +110,14 @@ int git_diff_config(const char *var, const char *value)
110
if (!strcmp(var, "diff.color")) {
111
if (!value)
112
diff_use_color_default = 1; /* bool */
113
- else if (!strcasecmp(value, "auto"))
114
- diff_use_color_default = isatty(1);
113
+ else if (!strcasecmp(value, "auto")) {
114
+ diff_use_color_default = 0;
115
+ if (isatty(1)) {
116
+ char *term = getenv("TERM");
117
+ if (term && strcmp(term, "dumb"))
118
+ diff_use_color_default = 1;
119
+ }
120
+ }
121
else if (!strcasecmp(value, "never"))
122
diff_use_color_default = 0;
123
else if (!strcasecmp(value, "always"))