From: Junio C Hamano Date: Tue, 08 May 2007 05:05:53 GMT Subject: Re: [PATCH] remove unnecessary loop Message-ID: <7virb352ha.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <4640015F.1080407@gmail.com> Liu Yubao writes: > Here is a ugly fix, I don't hope it will be merged into git tree as it's not > git's fault, I will file a bug report for Cygwin. > @@ -50,9 +53,18 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p > continue; > > /* Existing file? We must have ignored it */ > +#ifdef __CYGWIN__ > + /* > + * On cygwin, lstat("hello", &st) returns 0 when > + * "hello.exe" exists, so test with open() again. > + */ > + if (lstat(match, &st) && -1 != (fd = open(match, O_RDONLY))) { > + struct dir_entry *ent; > + close(fd); > +#else We have lstat() everywhere, so if we were to work this around without (or "waiting for") a proper fix on the Cygwin side, you would be better off wrapping the above sequence in a separate function (say "sane_lstat()"), and do #ifdef __CYGWIN__ #define lstat(a,b) sane_lstat(a,b) #endif somewhere near the top of git-compat-util.h