Skip to content

Commit bc980dc

Browse files
마누엘dscho
authored andcommitted
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>
1 parent 0f265e9 commit bc980dc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

compat/mingw.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,12 @@ int mingw_rename(const char *pold, const char *pnew)
16031603
if (gle == ERROR_ACCESS_DENIED &&
16041604
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
16051605
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;
16071612
return -1;
16081613
}
16091614
if ((attrs & FILE_ATTRIBUTE_READONLY) &&

0 commit comments

Comments
 (0)