Skip to content

Commit 8b01ec0

Browse files
cs96anddscho
authored andcommitted
mingw: fix colourization on Cygwin pseudo terminals
Git only colours the output and uses pagination if isatty() returns 1. MSYS2 and Cygwin emulate pseudo terminals via named pipes, meaning that isatty() returns 0. f7f90e0 (mingw: make isatty() recognize MSYS2's pseudo terminals (/dev/pty*), 2016-04-27) fixed this for MSYS2 terminals, but not for Cygwin. The named pipes that Cygwin and MSYS2 use are very similar. MSYS2 PTY pipes are called 'msys-*-pty*' and Cygwin uses 'cygwin-*-pty*'. This commit modifies the existing check to allow both MSYS2 and Cygwin PTY pipes to be identified as TTYs. Note that pagination is still broken when running Git for Windows from within Cygwin, as MSYS2's less.exe is spawned (and does not like to interact with Cygwin's PTY). This partially fixes #267 Signed-off-by: Alan Davies <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d63e351 commit 8b01ec0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compat/winansi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,12 @@ static void detect_msys_tty(int fd)
559559
name = nameinfo->Name.Buffer;
560560
name[nameinfo->Name.Length / sizeof(*name)] = 0;
561561

562-
/* check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') */
563-
if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty"))
562+
/*
563+
* Check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX')
564+
* or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX')
565+
*/
566+
if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) ||
567+
!wcsstr(name, L"-pty"))
564568
return;
565569

566570
/* init ioinfo size if we haven't done so */

0 commit comments

Comments
 (0)