Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-11-13 16:37:20 +0300
committerJunio C Hamano <gitster@pobox.com>2018-11-13 16:37:20 +0300
commitfbfdc07511283a111192e32970bee909016b47d2 (patch)
tree38c32f8ffcde50579a993e8a06163e688c1f284a /compat
parentbce4fc60caca82af9e02983abcbbc348d2aadfe4 (diff)
parentff8978d533207f472b183223d88786b1053f1989 (diff)
Merge branch 'js/mingw-isatty-and-dup2'
Windows fix. * js/mingw-isatty-and-dup2: mingw: fix isatty() after dup2()
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.h3
-rw-r--r--compat/winansi.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index 4c14e308353..a577df0d74a 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -406,6 +406,9 @@ int mingw_raise(int sig);
int winansi_isatty(int fd);
#define isatty winansi_isatty
+int winansi_dup2(int oldfd, int newfd);
+#define dup2 winansi_dup2
+
void winansi_init(void);
HANDLE winansi_get_osfhandle(int fd);
diff --git a/compat/winansi.c b/compat/winansi.c
index a11a0f16d27..f4f08237f9e 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -474,6 +474,18 @@ static void die_lasterr(const char *fmt, ...)
va_end(params);
}
+#undef dup2
+int winansi_dup2(int oldfd, int newfd)
+{
+ int ret = dup2(oldfd, newfd);
+
+ if (!ret && newfd >= 0 && newfd <= 2)
+ fd_is_interactive[newfd] = oldfd < 0 || oldfd > 2 ?
+ 0 : fd_is_interactive[oldfd];
+
+ return ret;
+}
+
static HANDLE duplicate_handle(HANDLE hnd)
{
HANDLE hresult, hproc = GetCurrentProcess();