From ba6fad02b6cbbfbf5acf3303b4d8ddfd8624fdb2 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 16 Nov 2014 22:06:26 +0100 Subject: [PATCH] Windows: correct detection of EISDIR in mingw_open() According to the Linux open(2) man page, open() must return EISDIR if a directory was attempted to be opened for writing. Our emulation in mingw_open() does not get this right: it checks only for O_CREAT. Fix it to check for a write request. This fixes a failure in reflog handling, which opens files with O_APPEND|O_WRONLY, but without O_CREAT, and expects EISDIR when the named file happens to be a directory. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/mingw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index c5c37e53ce..70f3191a4f 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -312,7 +312,7 @@ int mingw_open (const char *filename, int oflags, ...) return -1; fd = _wopen(wfilename, oflags, mode); - if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { + if (fd < 0 && (oflags & O_ACCMODE) != O_RDONLY && errno == EACCES) { DWORD attrs = GetFileAttributesW(wfilename); if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) errno = EISDIR; -- 2.11.4.GIT