Re: [PATCH] remove unnecessary loop
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:08
Liu Yubao [off-list ref] 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.
quoted hunk
@@ -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