Skip to content

Commit 4426fb5

Browse files
마누엘gitster
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: 마누엘 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fc7bf7 commit 4426fb5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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)