From: 마누엘 Date: Tue, 26 Jan 2016 14:34:47 +0000 (+0100) Subject: mingw: try to delete target directory before renaming X-Git-Tag: v2.8.0-rc0~54^2~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4426fb51421cdbf6f8d4c8dfb8bffd7adb51e034 mingw: try to delete target directory before renaming When the rename() function tries to move a directory it fails if the target directory exists. It should check if it can delete the (possibly empty) target directory and then try again to move the directory. This partially fixes t9100-git-svn-basic.sh. Signed-off-by: 마누엘 Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/compat/mingw.c b/compat/mingw.c index 717931e359..9e64f76bde 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1603,7 +1603,12 @@ int mingw_rename(const char *pold, const char *pnew) if (gle == ERROR_ACCESS_DENIED && (attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) { if (attrs & FILE_ATTRIBUTE_DIRECTORY) { - errno = EISDIR; + DWORD attrsold = GetFileAttributesW(wpold); + if (attrsold == INVALID_FILE_ATTRIBUTES || + !(attrsold & FILE_ATTRIBUTE_DIRECTORY)) + errno = EISDIR; + else if (!_wrmdir(wpnew)) + goto repeat; return -1; } if ((attrs & FILE_ATTRIBUTE_READONLY) &&