Johannes Sixt <j...@kdbg.org> writes:

> Not a comment, on this paragraph of yours, but while I was walking
> through the code with gdb, I was wondering why the reflog directory is
> being touched at all when core.logallrefupdates is off (in
> log_ref_setup via log_ref_write). With the patch below I now get the
> same unlink warning as on Linux.

I do not do Windows, but your analysis feels really sound and
explains the symptom well, and the change looks like the right fix
to the issue.

Thanks.

> --- 8< ---
> Subject: [PATCH] Windows: correct detection of EISDIR in mingw_open()
>
> According to the Linux open(2) man page, open() returns 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 one of the write flags.
>
> 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 <j...@kdbg.org>
> ---
>  compat/mingw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 2ee3fe3..fc64b73 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_WRONLY|O_RDWR)) && errno == EACCES) {
>               DWORD attrs = GetFileAttributesW(wfilename);
>               if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & 
> FILE_ATTRIBUTE_DIRECTORY))
>                       errno = EISDIR;
> -- 
> 2.0.0.12.gbcf935e
>
> -- 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to