summaryrefslogtreecommitdiff
path: root/compat/mingw.c
diff options
context:
space:
mode:
authorLibravatar 마누엘 <nalla@hamal.uberspace.de>2016-01-26 15:34:47 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-01-26 13:42:59 -0800
commit4426fb51421cdbf6f8d4c8dfb8bffd7adb51e034 (patch)
treee45467a6d979d71eb2e6d61e9fc110fb5f4f6161 /compat/mingw.c
parentmingw: prepare the TMPDIR environment variable for shell scripts (diff)
downloadtgif-4426fb51421cdbf6f8d4c8dfb8bffd7adb51e034.tar.xz
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>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r--compat/mingw.c7
1 files changed, 6 insertions, 1 deletions
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 @@ repeat:
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) &&