From: Linus Torvalds Date: Thu, 14 Jul 2005 16:52:48 GMT Subject: Re: Why O_EXCL would make this difference? I am puzzled.. Message-ID: In-Reply-To: On Thu, 14 Jul 2005, Linus Torvalds wrote: > > I'll strace the dang thing. It's the "Adding" case in git-merge-one-file-script, which does git-checkout-cache -u -f -- "$4" and it's because of this: lstat64("DF", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0 unlink("DF") = -1 EISDIR (Is a directory) .. unpack the object .. open("DF", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666) = -1 EEXIST (File exists) ie the problem is that we actually _have_ a test for this, but it's: if (errno == EISDIR && force) { but if the directory already exists, we do that wrong. Btw, this also shows a different problem: the symlink handling doesn't do any of this, so you cannot even force a directory to become a symlink. I think both problems can be fixed by just moving the (EISDIR && force) test down to the "unlink()". Will try. Linus