Skip to content

Teach msys2-runtime to hand the tty through to Git #28

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
Mar 11, 2015

Conversation

dscho
Copy link
Member

@dscho dscho commented Mar 9, 2015

When we were using winpty, the git log command called the pager correctly. However, without using winpty this is not the case. Most likely, there is a way to teach the msys2-runtime to special-case git.exe and pass the tty through so that Git knows that it is running inside a console.

Note: this is only an issue when not running in cmd.exe. However, we want to switch to a nicer terminal in the upcoming Git for Windows release.

@sschuberth
Copy link

[mintty] should be the default for the upcoming Git for Windows release

We haven't discussed this is yet IIRC, and IMO mintty should not be the default. Our goal is to provide a good native Git experience on Windows. It is not our goal to make MSYS2 tools in general work nicely on Windows.

That said, for native Windows applications there are better Consoles than mintty, in particular ConEmu (or its Cmder flavor) and Console Z (a Console 2 fork).

@dscho
Copy link
Member Author

dscho commented Mar 9, 2015

Frankly, I do not really care which terminal we use, as long as it is fully resizable and has a sane copy function (i.e. non-rectangular, but line selections). Both are offered by mintty, so I would be fine with it.

But even if we choose to ship with another terminal (which BTW would have to be bundled as a Pacman package to keep the script simple that makes the installer), we still need what this ticket is about: a way to teach msys2-runtime to hand through the tty to Git so that isatty() works correctly.

@dscho
Copy link
Member Author

dscho commented Mar 9, 2015

I updated the description of the ticket so it does not mention mintty anymore.

@dscho
Copy link
Member Author

dscho commented Mar 9, 2015

Hold on, something does not quite work yet.

@dscho
Copy link
Member Author

dscho commented Mar 9, 2015

Okay, now it works.

@sschuberth @t-b please have a look and continue to be merciless 😼

@dscho
Copy link
Member Author

dscho commented Mar 10, 2015

Please note that I pushed the fixup to master directly because the compilation failed without it (noticed by @nalla).

@sschuberth
Copy link

Could you also briefly explain why we didn't need this with MSYS1?

@dscho
Copy link
Member Author

dscho commented Mar 10, 2015

@sschuberth Apart from the retracted #ifdef comment, I addressed all your comments in e7b321d.

MSys2 has a slightly different notion of what constitutes a tty than
the Microsoft C runtime. The former knows whether stdin/stdout/stderr
was redirected or not, while the latter looks for a Win32 Console.

In particular when we want to know whether to spawn a pager or not, we
would rather want to know what MSys2 thinks.

We are about to introduce a change to the msys2-runtime that sets an
environment variable MSYS_TTY_HANDLES to a list of Win32 handles that
correspond to stdin/stdout/stderr, respectively, *but skips* handles that
MSys2 does not think are terminals.

This commit handles that input to augment the isatty() function to return
1 also when MSYS_TTY_HANDLES contains the corresponding handle.

The only time when Git needs to know whether a Console is attached or not
is when winansi.c is asked to Do Its Thing, therefore we refrain from
overriding isatty there.

Note: this was an issue with MSys1-based Git for Windows, too, hidden by
the fact that Git for Windows used `cmd.exe` as a terminal -- which is
backed by a real Win32 Console. Had MSys1 used, say, rxvt as its default
terminal, the symptom would have been that "git log" does not spawn a
pager by default but instead outputs the entire history (without color
coding, too). In MSys2, the default terminal is mintty, therefore we
finally could not avoid to address the issue.

Signed-off-by: Johannes Schindelin <[email protected]>
@sschuberth
Copy link

Looks good to me now. I'll leave the merge to you to sync with git-for-windows/msys2-runtime#4.

dscho added a commit that referenced this pull request Mar 11, 2015
Teach msys2-runtime to hand the tty through to Git
@dscho dscho merged commit 8c01ab4 into git-for-windows:master Mar 11, 2015
@dscho dscho deleted the tty-handles branch March 11, 2015 19:07
@dscho
Copy link
Member Author

dscho commented Mar 11, 2015

Thanks, @sschuberth!

dscho added a commit that referenced this pull request Mar 21, 2015
Teach msys2-runtime to hand the tty through to Git
dscho pushed a commit that referenced this pull request Mar 24, 2015
Teach msys2-runtime to hand the tty through to Git
dscho pushed a commit that referenced this pull request Mar 30, 2015
Teach msys2-runtime to hand the tty through to Git
jeffhostetler added a commit to jeffhostetler/git that referenced this pull request Oct 10, 2018
(Experimental) Trace2 base plus GVFS extensions
jamill pushed a commit to jamill/git that referenced this pull request Nov 20, 2018
(Experimental) Trace2 base plus GVFS extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants