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

Re: [RFC/PATCH 0/1] cygwin: Remove the Win32 l/stat() functions

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2013, 19:50 UTC
Message-ID
<7v4ncfjs32.fsf@alter.siamese.dyndns.org>
In-Reply-To
<51D06AC8.70206@ramsay1.demon.co.uk>
Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:
Show 31 quoted lines
> Ramsay Jones wrote:
>> Michael Haggerty wrote:
>>> On 06/27/2013 12:35 AM, Jeff King wrote:
>> [ ... ]
>>>> I think Michael's assessment above is missing one thing.
>>>
>>> Peff is absolutely right; for some unknown reason I was thinking of the
>>> consistency check as having been already fixed.
>> 
>> Well, the "cygwin: Remove the Win32 l/stat() functions" patch *does* fix
>> the problem. :-D It's just a pity we can't use it on performance grounds. :(
>> 
>>>> [...#ifdef out consistency check on cygwin when lock is held...]
>>>
>>> Yes, this would work.
>>>
>>> But, taking a step back, I think it is a bad idea to have an unreliable
>>> stat() masquerading as a real stat().  If we want to allow the use of an
>>> unreliable stat for certain purposes, let's have two stat() interfaces:
>>>
>>> * the true stat() (in this case I guess cygwin's slow-but-correct
>>> implementation)
>>>
>>> * some fast_but_maybe_unreliable_stat(), which would map to stat() on
>>> most platforms but might map to the Windows stat() on cygwin when so
>>> configured.
>>>
>>> By default the true stat() would always be used.  It should have to be a
>>> conscious decision, taken only in specific, vetted scenarios, to use the
>>> unreliable stat.
>>  ...

I like the part that gets rid of that "get-mode-bits" but at the same time, I find this part wanting a reasonable in-code comment.

At least, with the earlier get-mode-bits, it was clear why we are doing something special in that codepath, both from the name of the helper function/macro and the comment attached to it describing how the "regular" one is cheating.

We must say why this "fast" is not used everywhere and what criteria you should apply when deciding to use it (or not use it). And the "fast" name is much less descriptive.

I suspect (without thinking it through) that the rule would be something like:

    The "fast" variant is to be used to read from the filesystem the
    "stat" bits that are stuffed into the index for quick "touch
    detection" (aka "cached stat info") and/or that are compared
    with the cached stat info, and should not be used anywhere else.
But then we always use lstat(2) and not stat(2) for that, so...
Show 10 quoted lines
> +#ifndef GIT_FAST_STAT
> +static inline int fast_stat(const char *path, struct stat *st)
> +{
> +	return stat(path, st);
> +}
> +static inline int fast_lstat(const char *path, struct stat *st)
> +{
> +	return lstat(path, st);
> +}
> +#endif
Previous: Ramsay JonesNext: Ramsay Jones
Message 20 of 24 in “Re: [RFC/PATCH 0/1] cygwin: Remove the Win32 l/stat() functions”
  1. Johannes SixtJun 25, 2013
  2. Torsten BögershausenJun 25, 2013
  3. Junio C HamanoJun 25, 2013
  4. Torsten BögershausenJun 26, 2013
  5. Ramsay JonesJun 26, 2013
  6. Torsten BögershausenJun 27, 2013
  7. Ramsay JonesJun 27, 2013
  8. Mark LevedahlJun 27, 2013
  9. Ramsay JonesJun 26, 2013
  10. Ramsay JonesJun 26, 2013
  11. Jeff KingJun 26, 2013
  12. Jeff KingJun 26, 2013
  13. Ramsay JonesJun 27, 2013
  14. Mark LevedahlJun 28, 2013
  15. Michael HaggertyJun 27, 2013
  16. Jeff KingJun 27, 2013
  17. Junio C HamanoJun 27, 2013
  18. Ramsay JonesJun 27, 2013
  19. Ramsay JonesJun 30, 2013
  20. Junio C HamanoJun 30, 2013
  21. Ramsay JonesJul 4, 2013
  22. Torsten BögershausenJul 9, 2013
  23. Ramsay JonesJul 11, 2013
  24. Ramsay JonesJun 27, 2013

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.