]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mingw: make stderr unbuffered again
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 13 Feb 2017 22:34:06 +0000 (23:34 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 14 Feb 2017 18:54:21 +0000 (10:54 -0800)
When removing the hack for isatty(), we actually removed more than just
an isatty() hack: we removed the hack where internal data structures of
the MSVC runtime are modified in order to redirect stdout/stderr.

Instead of using that hack (that does not work with newer versions of
the runtime, anyway), we replaced it by reopening the respective file
descriptors.

What we forgot was to mark stderr as unbuffered again.

Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Tested-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/winansi.c

index 56658ec4f804630fa15791f78fb5df9a8fc0ea69..dac5d01c53e52f75bc6b1d4181fe9cdf9397b2ca 100644 (file)
@@ -510,6 +510,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
         */
        close(new_fd);
 
+       if (fd == 2)
+               setvbuf(stderr, NULL, _IONBF, BUFSIZ);
        fd_is_interactive[fd] |= FD_SWAPPED;
 
        return duplicate;
@@ -547,6 +549,8 @@ static void detect_msys_tty(int fd)
                        !wcsstr(name, L"-pty"))
                return;
 
+       if (fd == 2)
+               setvbuf(stderr, NULL, _IONBF, BUFSIZ);
        fd_is_interactive[fd] |= FD_MSYS;
 }