From e7cae66140fe451f9e488aa1c4d9a8be99dd1cec Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Sat, 31 Jul 2010 00:04:00 +0000 Subject: [PATCH] Enable color output in Windows cmd.exe Git requires the TERM environment variable to be set for all color* settings. Simulate the TERM variable if it is not set (default on Windows). Signed-off-by: Karsten Blees Signed-off-by: Johannes Schindelin --- compat/mingw.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 48a3b760d9..318c6560ec 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -668,11 +668,16 @@ char *mingw_getcwd(char *pointer, int len) char *mingw_getenv(const char *name) { char *result = getenv(name); - if (!result && !strcmp(name, "TMPDIR")) { - /* on Windows it is TMP and TEMP */ - result = getenv("TMP"); - if (!result) - result = getenv("TEMP"); + if (!result) { + if (!strcmp(name, "TMPDIR")) { + /* on Windows it is TMP and TEMP */ + result = getenv("TMP"); + if (!result) + result = getenv("TEMP"); + } else if (!strcmp(name, "TERM")) { + /* simulate TERM to enable auto-color (see color.c) */ + result = "winansi"; + } } return result; } -- 2.11.4.GIT