Skip to content

Commit 22a888e

Browse files
dschokblees
authored andcommitted
Revert "mingw: Work around MSVCRT's isatty() not knowing about MSys2"
This reverts commit 04cde24. The MSYS_TTY_HANDLES trick doesn't work in a second shell window. Additionally, #undef'ing 'isatty()' at the top of mingw.c breaks yes / no questions (ask_yes_no_if_possible()) and probably other uses of isatty() in mingw.c. Signed-off-by: Karsten Blees <[email protected]>
1 parent ca15bb6 commit 22a888e

File tree

3 files changed

+0
-42
lines changed

3 files changed

+0
-42
lines changed

compat/mingw.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "../run-command.h"
77
#include "../cache.h"
88

9-
#undef isatty
10-
119
#define HCAST(type, handle) ((type)(intptr_t)handle)
1210

1311
static const int delay[] = { 0, 1, 10, 20, 40 };
@@ -2380,38 +2378,3 @@ void mingw_startup()
23802378
/* init length of current directory for handle_long_path */
23812379
current_directory_len = GetCurrentDirectoryW(0, NULL);
23822380
}
2383-
2384-
int mingw_isatty(int fd) {
2385-
static DWORD id[] = {
2386-
STD_INPUT_HANDLE,
2387-
STD_OUTPUT_HANDLE,
2388-
STD_ERROR_HANDLE
2389-
};
2390-
static unsigned initialized;
2391-
static int is_tty[ARRAY_SIZE(id)];
2392-
2393-
if (fd < 0 || fd >= ARRAY_SIZE(is_tty))
2394-
return isatty(fd);
2395-
2396-
if (isatty(fd))
2397-
return 1;
2398-
2399-
if (!initialized) {
2400-
const char *env = getenv("MSYS_TTY_HANDLES");
2401-
2402-
if (env) {
2403-
int i;
2404-
char buffer[64];
2405-
2406-
for (i = 0; i < ARRAY_SIZE(is_tty); i++) {
2407-
sprintf(buffer, " %" PRIuMAX " ",
2408-
HCAST(uintmax_t, GetStdHandle(id[i])));
2409-
is_tty[i] = !!strstr(env, buffer);
2410-
}
2411-
}
2412-
2413-
initialized = 1;
2414-
}
2415-
2416-
return is_tty[fd];
2417-
}

compat/mingw.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,6 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler);
367367
int mingw_raise(int sig);
368368
#define raise mingw_raise
369369

370-
int mingw_isatty(int fd);
371-
#define isatty mingw_isatty
372-
373370
/*
374371
* ANSI emulation wrappers
375372
*/

compat/winansi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <wingdi.h>
88
#include <winreg.h>
99

10-
#undef isatty
11-
1210
/*
1311
ANSI codes used by git: m, K
1412

0 commit comments

Comments
 (0)