git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>
Subject: [PATCH] Fix merge-recursive on cygwin: broken errno when unlinking a directory
Date: Thu, 19 Apr 2007 00:33:27 +0200	[thread overview]
Message-ID: <20070418223327.GC2477@steel.home> (raw)

Looks like this time it is not cygwin, the you-know-what actually does
return a permission error.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

I am very tempted to conditionally #define gitunlink
to say something rude about win32 and delete c:\boot.ini
instead. It will even work, in most setups.

 merge-recursive.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 595b022..ae4032b 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -610,16 +610,19 @@ static void update_file_flags(const unsigned char *sha,
 				die(msg, path, "");
 			}
 			if (unlink(path)) {
-				if (errno == EISDIR) {
+				struct stat st;
+				int err = errno;
+				if (err == EISDIR ||
+				    (err == EPERM && !lstat(path, &st) && S_ISDIR(st.st_mode))) {
 					/* something else exists */
 					error(msg, path, ": perhaps a D/F conflict?");
 					update_wd = 0;
 					goto update_index;
 				}
-				if (errno != ENOENT)
+				if (err != ENOENT)
 					die("failed to unlink %s "
 					    "in preparation to update: %s",
-					    path, strerror(errno));
+					    path, strerror(err));
 			}
 			if (mode & 0100)
 				mode = 0777;
-- 
1.5.1.1.876.ge36f76

             reply	other threads:[~2007-04-18 22:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-18 22:33 Alex Riesen [this message]
2007-04-18 23:04 ` [PATCH] Fix merge-recursive on cygwin: broken errno when unlinking a directory Linus Torvalds
2007-04-18 23:40   ` Alex Riesen
2007-04-19  8:28     ` Alex Riesen
2007-04-19 16:39       ` Linus Torvalds
2007-04-19 18:31         ` Sam Ravnborg

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=20070418223327.GC2477@steel.home \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).