git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: msysgit@googlegroups.com, johannes.schindelin@gmx.de
Subject: [PATCH] mingw_rmdir: do not prompt for retry when non-empty
Date: Tue,  4 Dec 2012 11:41:53 +0100	[thread overview]
Message-ID: <1354617713-7436-1-git-send-email-kusmabite@gmail.com> (raw)

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 simply returning from the function instead of breaking
the loop.

While we're at it, change the second break to a return as well; we
already know that we won't enter the prompting-loop, beacuse
is_file_in_use_error(GetLastError()) already evaluated to false.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---

Here's a quick patch for a small issue I recently encountered; when
deleting a file from inside a directory, we currently end up
prompting the user if (s)he want us to retry deleting the directory
they are in.

 compat/mingw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 1eb974f..2c29667 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -260,10 +260,10 @@ int mingw_rmdir(const char *pathname)
 
 	while ((ret = _wrmdir(wpathname)) == -1 && tries < ARRAY_SIZE(delay)) {
 		if (!is_file_in_use_error(GetLastError()))
-			break;
+			return ret;
 		if (!is_dir_empty(wpathname)) {
 			errno = ENOTEMPTY;
-			break;
+			return ret;
 		}
 		/*
 		 * We assume that some other process had the source or
-- 
1.8.0.msysgit.0.3.g0262b9f.dirty

-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

             reply	other threads:[~2012-12-04 10:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 10:41 Erik Faye-Lund [this message]
2012-12-04 16:35 ` [PATCH] mingw_rmdir: do not prompt for retry when non-empty Johannes Schindelin
2012-12-05 15:18   ` Erik Faye-Lund
2012-12-05 16:02     ` Johannes Schindelin
2012-12-05 16:23       ` Erik Faye-Lund
2012-12-05 17:00         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1354617713-7436-1-git-send-email-kusmabite@gmail.com \
    --to=kusmabite@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=msysgit@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).