From: Frank Li Date: Mon, 17 Aug 2009 16:04:58 GMT Subject: [PATCH 07/11] Add O_BINARY flag to open flag at mingw.c Message-ID: <1250525103-5184-2-git-send-email-lznuaa@gmail.com> In-Reply-To: <1250525103-5184-1-git-send-email-lznuaa@gmail.com> Windows will convert CR\LF and union code at text mode. Git doesn't like this. Add O_BINARY flag to open function Signed-off-by: Frank Li --- compat/mingw.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 75c74b1..d5fa0ed 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -132,7 +132,7 @@ int mingw_open (const char *filename, int oflags, ...) if (!strcmp(filename, "/dev/null")) filename = "nul"; - fd = open(filename, oflags, mode); + fd = open(filename, oflags | O_BINARY, mode); if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { DWORD attrs = GetFileAttributes(filename); @@ -278,7 +278,7 @@ int mkstemp(char *template) char *filename = mktemp(template); if (filename == NULL) return -1; - return open(filename, O_RDWR | O_CREAT, 0600); + return open(filename, O_RDWR | O_CREAT | O_BINARY, 0600); } int gettimeofday(struct timeval *tv, void *tz) -- 1.6.4.msysgit.0