git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix merge-recursive on cygwin: broken errno when unlinking a directory

From
Alex Riesen <raa.lkml@gmail.com>
Date
Apr 18, 2007, 22:33 UTC
Message-ID
<20070418223327.GC2477@steel.home>

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
Next: Linus Torvalds
Message 1 of 6 in “Fix merge-recursive on cygwin: broken errno when unlinking a directory”
  1. Fix merge-recursive on cygwin: broken errno when unlinking a directoryAlex Riesen, Apr 18, 2007
  2. Linus TorvaldsApr 18, 2007
  3. Alex RiesenApr 18, 2007
  4. Alex RiesenApr 19, 2007
  5. Linus TorvaldsApr 19, 2007
  6. Sam RavnborgApr 19, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.