Merge branch 'js/windows-open-eisdir-error' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:17:13 +0000 (12:17 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:17:13 +0000 (12:17 -0800)
open() emulated on Windows platforms did not give EISDIR upon an
attempt to open a directory for writing.

* js/windows-open-eisdir-error:
Windows: correct detection of EISDIR in mingw_open()

compat/mingw.c
index c5c37e53ce0fc534b1739a75c4abde0c67027d14..70f3191a4f19f10a156d1f2c054943d5147ab049 100644 (file)
@@ -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;