mingw_rmdir: do not prompt for retry when non-empty

in ab1a11be ("mingw_rmdir: set errno=ENOTEMPTY when appropriate"), a check was added to prevent us from retrying to delete a directory that is both in use and non-empty. However, this logic was slightly flawed; since we didn't return immediately, we end up falling out of the retry-loop, but right into the prompting-loop. Fix this by setting errno, and guarding the prompting-loop with an errno-check. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Erik Faye-Lund committed Dec 10, 2012 at 15:42 UTC a83b2b578c04a2abe33a586ec9c64e75ef5bc819
1 file changed +3 -1
compat/mingw.c
+3 -1
@@ -256,6 +256,8 @@ int mingw_rmdir(const char *pathname)
256
257 while ((ret = rmdir(pathname)) == -1 && tries < ARRAY_SIZE(delay)) {
258 if (!is_file_in_use_error(GetLastError()))
259 + errno = err_win_to_posix(GetLastError());
260 + if (errno != EACCES)
261 break;
262 if (!is_dir_empty(pathname)) {
263 errno = ENOTEMPTY;
@@ -271,7 +273,7 @@ int mingw_rmdir(const char *pathname)
273 Sleep(delay[tries]);
274 tries++;
275 }
274 - while (ret == -1 && is_file_in_use_error(GetLastError()) &&
276 + while (ret == -1 && errno == EACCES && is_file_in_use_error(GetLastError()) &&
277 ask_yes_no_if_possible("Deletion of directory '%s' failed. "
278 "Should I try again?", pathname))
279 ret = rmdir(pathname);