Skip to content

Commit 0caf6c4

Browse files
cs96anddscho
authored andcommitted
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 3adef8d 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 #267 Signed-off-by: Alan Davies <[email protected]>
1 parent 434f0b2 commit 0caf6c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compat/winansi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,10 @@ static void detect_msys_tty(int fd)
551551
name = nameinfo->Name.Buffer;
552552
name[nameinfo->Name.Length] = 0;
553553

554-
/* check if this could be a msys pty pipe ('msys-XXXX-ptyN-XX') */
555-
if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty"))
554+
/* check if this could be a msys pty pipe ('msys-XXXX-ptyN-XX')
555+
or a cygwin pty pipe ('cygwin-XXXX-ptyN-XX') */
556+
if ((!wcsstr(name, L"msys-") && !wcsstr(name, L"cygwin-")) ||
557+
!wcsstr(name, L"-pty"))
556558
return;
557559

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

0 commit comments

Comments
 (0)