Win32: detect console streams more reliably
commit143e615270bd17dcef0d8e5751dacc496eff687d
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Jun 2014 20:32:44 +0000 (10 13:32 -0700)
tree00264af173b8d49d1c9ef2cc5ba80aa7c0ee49ce
parent617ce965aa3e5d44d0292c9094ee692f161a55d0
Win32: detect console streams more reliably

GetStdHandle(STD_OUTPUT_HANDLE) doesn't work for stderr if stdout is
redirected. Use _get_osfhandle of the FILE* instead.

_isatty() is true for all character devices (including parallel and serial
ports). Check return value of GetConsoleScreenBufferInfo instead to
reliably detect console handles (also don't initialize internal state from
an uninitialized CONSOLE_SCREEN_BUFFER_INFO structure if the function
fails).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/winansi.c