mirror of
https://github.com/git/git.git
synced 2026-02-06 16:01:36 +00:00
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 <johannes.schindelin@gmx.de>