1
0
mirror of https://github.com/git/git.git synced 2024-09-29 15:31:53 +02:00

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>
This commit is contained in:
Junio C Hamano 2006-07-07 17:48:02 -07:00
parent 6bdca89057
commit a0c2089c1d

10
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"))