Skip to content

Commit

Permalink
colored diff: diff.color = auto fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jul 8, 2006
1 parent 6bdca89 commit a0c2089
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit a0c2089

Please sign in to comment.