git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix a long-standing isatty() problem on Windows
@ 2016-12-11 11:16 Johannes Schindelin
  2016-12-11 11:16 ` [PATCH 1/1] mingw: intercept isatty() to handle /dev/null as Git expects it Johannes Schindelin
  2016-12-11 17:49 ` [PATCH 0/1] Fix a long-standing isatty() problem on Windows Junio C Hamano
  0 siblings, 2 replies; 21+ messages in thread
From: Johannes Schindelin @ 2016-12-11 11:16 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Pranit Bauva

I finally got a chance to debug the problems with the ever-timing-out
test runs of `pu` on Windows. Turns out that pb/bisect uncovered a
really old, really bad bug: on Windows, isatty() does not do what Git
expects, at least not completely: it detects interactive terminals *and
character devices*.

Why is this such a big deal?

One such character device is NUL, Windows' equivalent of /dev/null. And
guess what happens when the new tests of the bisect--helper run, with
stdin redirected from /dev/null? Precisely. Git asks "the user" for
reassurance that it may really continue, waiting forever. Or for Ctrl+C.

As we know what Git's source code wants, we have to make extra certain
to test whether isatty() reports success for a Console. The common way
to do this is to run GetConsoleMode() for input file descriptors, and
GetConsoleScreenBufferInfo() for output file descriptors.

One additional note: the new winansi_isatty() function was put into this
particular spot not only because it vaguely makes sense to put
tty-related stuff into compat/winansi.c, but with required future
changes in mind:

The current way in which Git for Windows makes sure that isatty()
returns non-zero for Git Bash (which runs in a terminal emulator called
MinTTY that does *not* have any Windows Console associated with it, and
therefore Windows' _isatty() would actually return 0 if it was not for
our detect_msys_tty() function) is hacky and needs to be fixed properly.

It is hacky because it relies on internals of the MSVC runtime that do
not hold true for the new Universal runtimes, which are used when
compiling with Visual C.

We already have experimental code to future-proof this method, and we
use that already when compiling Git for Windows in Visual Studio.

The place in which winansi_isatty() now lives will hopefully make it
possible to unify the code paths again, so that both GCC and Visual C
use detect_msys_tty() through winansi_isatty().

This will also fix a bug where current Visual C-built Git may misdetect
a reopened stdin to be connected to an interactive terminal.


Johannes Schindelin (1):
  mingw: intercept isatty() to handle /dev/null as Git expects it

 compat/mingw.h   |  3 +++
 compat/winansi.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)


base-commit: 8d7a455ed52e2a96debc080dfc011b6bb00db5d2
Published-As: https://github.com/dscho/git/releases/tag/mingw-isatty-v1
Fetch-It-Via: git fetch https://github.com/dscho/git mingw-isatty-v1

-- 
2.11.0.rc3.windows.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-12-22  9:23 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-11 11:16 [PATCH 0/1] Fix a long-standing isatty() problem on Windows Johannes Schindelin
2016-12-11 11:16 ` [PATCH 1/1] mingw: intercept isatty() to handle /dev/null as Git expects it Johannes Schindelin
2016-12-16 17:48   ` Johannes Sixt
2016-12-16 18:08     ` Junio C Hamano
2016-12-16 18:44       ` Johannes Sixt
2016-12-16 19:05         ` Junio C Hamano
2016-12-21 17:56           ` Johannes Schindelin
2016-12-18 15:26         ` [PATCH] winansi_isatty(): fix when Git is used from CMD Johannes Sixt
2016-12-18 15:37           ` Johannes Sixt
2016-12-19 19:34             ` Johannes Sixt
2016-12-21 17:57               ` Johannes Schindelin
2016-12-20 16:53             ` Johannes Schindelin
2016-12-19  1:12           ` Junio C Hamano
2016-12-20 16:50           ` Johannes Schindelin
2016-12-20 16:59             ` Junio C Hamano
2016-12-21 17:59               ` Johannes Schindelin
2016-12-21 18:54                 ` Junio C Hamano
2016-12-22  9:23                   ` Johannes Schindelin
2016-12-11 17:49 ` [PATCH 0/1] Fix a long-standing isatty() problem on Windows Junio C Hamano
2016-12-12  9:59   ` Johannes Schindelin
2016-12-12 16:46     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).