]> git.ipfire.org Git - thirdparty/git.git/commitdiff
colored diff: diff.color = auto fix
authorJunio C Hamano <junkio@cox.net>
Sat, 8 Jul 2006 00:48:02 +0000 (17:48 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 8 Jul 2006 00:48:02 +0000 (17:48 -0700)
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>
diff.c

diff --git a/diff.c b/diff.c
index f0450a8b0bcefc336b6aa5e3d5122c1a3a39b1a4..aab246c97eb1660acfa231f7008180a12f6deb8d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -110,8 +110,14 @@ int git_diff_config(const char *var, const char *value)
        if (!strcmp(var, "diff.color")) {
                if (!value)
                        diff_use_color_default = 1; /* bool */
-               else if (!strcasecmp(value, "auto"))
-                       diff_use_color_default = isatty(1);
+               else if (!strcasecmp(value, "auto")) {
+                       diff_use_color_default = 0;
+                       if (isatty(1)) {
+                               char *term = getenv("TERM");
+                               if (term && strcmp(term, "dumb"))
+                                       diff_use_color_default = 1;
+                       }
+               }
                else if (!strcasecmp(value, "never"))
                        diff_use_color_default = 0;
                else if (!strcasecmp(value, "always"))