Skip to content

winansi.c: Fix colourization on Cygwin pseudo terminals. #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2015
Merged

winansi.c: Fix colourization on Cygwin pseudo terminals. #275

merged 1 commit into from
Aug 17, 2015

Conversation

cs96and
Copy link

@cs96and cs96and commented Aug 13, 2015

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

@dscho
Copy link
Member

dscho commented Aug 17, 2015

Yes, please, as a single commit. Just use git commit --amend to fix the commit message and then force-push (git push <remote> +HEAD) to update this Pull Request. Thanks.

@cs96and
Copy link
Author

cs96and commented Aug 17, 2015

When you say "re-wrap at 76 columns/line" are you talking about the source code or the commit message?

@dscho
Copy link
Member

dscho commented Aug 17, 2015

When you say "re-wrap at 76 columns/line" are you talking about the source code or the commit message?

Just the commit message. Source code should be wrapped at 80 columns/line. Thank you!

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]>
dscho added a commit that referenced this pull request Aug 17, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
@dscho dscho merged commit 156b212 into git-for-windows:master Aug 17, 2015
@dscho
Copy link
Member

dscho commented Aug 17, 2015

Thank you!

BTW is the first less.exe in your PATH Git for Windows' one, or is it Cygwin's?

@cs96and
Copy link
Author

cs96and commented Aug 17, 2015

If I don't specify the pager, then Msys's less.exe gets spawned (In process explorer I see C:\Program Files\Git\usr\bin\less.exe getting spawned).

I tried overriding the pager using the PAGER and GIT PAGER variables to use cygwin's less.exe. In Process Explorer I now see c:\cygwin\bin\less.exe getting spawned, but it makes no difference. Git's output goes flying up the screen, as if it is not being piped into less

@dscho
Copy link
Member

dscho commented Aug 17, 2015

Hmm. I guess this needs serious investigation, still. Unfortunately I do not have the time right now, preparing the release...

@dscho
Copy link
Member

dscho commented Aug 17, 2015

(In order not to forget, and to give volunteers a chance to work on it, I reopened #267.)

dscho added a commit that referenced this pull request Aug 31, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Sep 10, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Sep 18, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Sep 29, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Oct 5, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Oct 19, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Nov 9, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Dec 11, 2015
winansi.c: Fix colourization on Cygwin pseudo terminals.
dscho added a commit that referenced this pull request Jan 5, 2016
winansi.c: Fix colourization on Cygwin pseudo terminals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pagination and colour do not work from a minTTY cygwin prompt
2 participants