From: Johannes Schindelin Date: Mon, 13 Feb 2017 22:34:06 +0000 (+0100) Subject: mingw: make stderr unbuffered again X-Git-Tag: v2.12.0-rc2~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4d92d579f792e8eac4f7cf590bfffc522bf3da9;p=thirdparty%2Fgit.git mingw: make stderr unbuffered again 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 Tested-by: Johannes Sixt Signed-off-by: Junio C Hamano --- diff --git a/compat/winansi.c b/compat/winansi.c index 56658ec4f8..dac5d01c53 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -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; }