From 1dce46129c295c50cd717bc31ccbe7fafb9ab703 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Sat, 11 Feb 2012 00:58:37 +0100 Subject: [PATCH] Win32: fix deletion of .git/objects sub-directories in git-repack On Windows XP (not Win7), directories cannot be deleted while a find handle is open, causing "Deletion of directory '...' failed. Should I try again?" prompts in git-repack and git-gc. Prior to 19d1e75d "Win32: Unicode file name support (except dirent)", these failures were silently ignored due to strbuf_free in is_dir_empty resetting GetLastError to ERROR_SUCCESS. Close find handles properly before trying to delete directories. Reported-by: John Chen Signed-off-by: Karsten Blees --- compat/mingw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index a0ac487c0c..71a04c5a30 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -238,11 +238,12 @@ static int is_dir_empty(const char *path) return GetLastError() == ERROR_NO_MORE_FILES; } - while (!strcmp(findbuf.cFileName, ".") || - !strcmp(findbuf.cFileName, "..")) - if (!FindNextFile(handle, &findbuf)) { - strbuf_release(&buf); - return GetLastError() == ERROR_NO_MORE_FILES; + while (!wcscmp(findbuf.cFileName, L".") || + !wcscmp(findbuf.cFileName, L"..")) + if (!FindNextFileW(handle, &findbuf)) { + DWORD err = GetLastError(); + FindClose(handle); + return err == ERROR_NO_MORE_FILES; } FindClose(handle); strbuf_release(&buf);