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

Re: [PATCH] remove unnecessary loop

From
Junio C Hamano <junkio@cox.net>
Date
May 8, 2007, 05:05 UTC
Message-ID
<7virb352ha.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<4640015F.1080407@gmail.com>
Liu Yubao <yubao.liu@gmail.com> 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.
Show 13 quoted lines
> @@ -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
Previous: Liu YubaoNext: Alex Riesen
Message 3 of 9 in “remove unnecessary loop”
  1. remove unnecessary loopLiu Yubao, May 8, 2007
  2. Liu YubaoMay 8, 2007
  3. Junio C HamanoMay 8, 2007
  4. Alex RiesenMay 8, 2007
  5. Jan HudecMay 8, 2007
  6. Alex RiesenMay 8, 2007
  7. Eric BlakeMay 8, 2007
  8. Jan HudecMay 8, 2007
  9. Liu YubaoMay 9, 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.