From 4e0f44c8890eae7e351b32d25c654ccfc65803ce Mon Sep 17 00:00:00 2001 From: Alan Davies Date: Thu, 13 Aug 2015 11:15:44 +0100 Subject: [PATCH] winansi.c: Fix colourization on Cygwin pseudo terminals. Git only colours the output and uses pagination if isatty() returns 1. MSys and Cygwin emulate pseudo terminals via named pipes, meaning that isatty() returns 0. Commit 3adef8de5513390459e1caa999e7774adb89a44d fixed this for MSys terminals, but not Cygwin. The named pipes that Cygwin and Msys use are very similar. MSys PTY pipes are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'. This commit modifies the existing check to allow both MSys and Cygwin PTY pipes to be identified as TTYs. Note that Pagination is still broken on Cygwin. less.exe is spawned (as seen in Process Explorer and using GIT_TRACE=1), but the output is not being piped into it. This partially fixes https://github.com/git-for-windows/git/issues/267 Signed-off-by: Alan Davies --- compat/winansi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compat/winansi.c b/compat/winansi.c index db4a5b0a37..54af2c5cf0 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -555,8 +555,12 @@ static void detect_msys_tty(int fd) name = nameinfo->Name.Buffer; name[nameinfo->Name.Length] = 0; - /* check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') */ - if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty")) + /* + * Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') + * or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX') + */ + if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) || + !wcsstr(name, L"-pty")) return; /* init ioinfo size if we haven't done so */