Re: [PATCH 06/19] mingw: try to delete target directory before renaming
- From
Philip Oakley <philipoakley@iee.org>
- Date
- Jan 24, 2016, 16:36 UTC
- Message-ID
- <4C2ED807DD184A168C87221809034B70@PhilipOakley>
- In-Reply-To
- <d75b0dc0b76beefee9e705555ca4f2fa4f4b96ce.1453650173.git.johannes.schindelin@gmx.de>
From: "Johannes Schindelin" <johannes.schindelin@gmx.de>
>From: 마누엘 <nalla@users.noreply.github.com>
Is this Nalla's preferred email, or just a carry over from cautions of the Github interface?
Show 33 quoted lines
>
>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@users.noreply.github.com>
>Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>---
>compat/mingw.c | 7 ++++++-
>1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/compat/mingw.c b/compat/mingw.c
>index db92f5d..e4839b9 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) &&
>--
>2.7.0.windows.1.7.g55a05c8-- Philip