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: 마누엘 <nalla@hamal.uberspace.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

마누엘 committed Jan 26, 2016 at 15:34 UTC 4426fb51421cdbf6f8d4c8dfb8bffd7adb51e034
1 file changed +6 -1
compat/mingw.c
+6 -1
@@ -1603,7 +1603,12 @@ repeat:
1603 if (gle == ERROR_ACCESS_DENIED &&
1604 (attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
1605 if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
1606 - errno = EISDIR;
1606 + DWORD attrsold = GetFileAttributesW(wpold);
1607 + if (attrsold == INVALID_FILE_ATTRIBUTES ||
1608 + !(attrsold & FILE_ATTRIBUTE_DIRECTORY))
1609 + errno = EISDIR;
1610 + else if (!_wrmdir(wpnew))
1611 + goto repeat;
1612 return -1;
1613 }
1614 if ((attrs & FILE_ATTRIBUTE_READONLY) &&