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

Re: [PATCH] Fix update-index --refresh for submodules if stat(2) returns st_size 0

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2008, 08:07 UTC
Message-ID
<7vbq0qnxyi.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080721194322.GA4013@blimp.local>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 15 quoted lines
> Johannes Schindelin, Mon, Jul 21, 2008 20:20:43 +0200:
>> Hi,
>> 
>> On Mon, 21 Jul 2008, Alex Riesen wrote:
>> 
>> > For example - Cygwin.
>> 
>> Please enhance: your oneline is too long, and your commit message body too 
>> short.
>
> Well, I'm really not sure. I just found this difference between linux
> and cygwin (st_stat is 0 for dirs on cygwin). Than I noticed that the
> routine where I made the change explicitely checks for st_size not
> being 0. I must admit I can't make much out of comment, and hope this
> discussion will help to clear the check up.

The cached stat information in the index is used to speed up comparison between "the last staged data" and what is in the working tree. ie_match_stat() compares ce_xxx fields with the result from lstat(2) we just did, and if there are differences, we take it as a sign that what's in the working tree is different from what we saw when we updated the index entry.

But there is a twist.

Ordinarily, when an entry enteres the index, the hash of the blob contents goes along with the lstat(2) information taken from the file that supplied the contents. However there are some cases we populate the index without lstat(2). update-index --cacheinfo, update-index --index-info are two examples, and when they add index entries, they leave ce_size field to zero. ie_match_stat() will compare that zero ce_size with the size information obtained from the working tree, and declare (falsely) that "what's in the working tree is different -- it can never match, and there is no point trying to re-index to see if they actually match", even though the reason ce_size is zero is *not* because we observed the size of the working tree file *was* zero when we indexed it the last time (it is zero merely because we haven't looked at it yet). The ce_modified_check_fs() call is there to deal with this "we cannot trust the ce_xxx fields" case.

I however have to wonder if you also need to touch the end of ce_match_stat_basic() that checks for zero sized cache entry.

Previous: Johannes SchindelinNext: Alex Riesen
Message 5 of 41 in “Fix update-index --refresh for submodules if stat(2) returns st_size 0”
  1. Fix update-index --refresh for submodules if stat(2) returns st_size 0Alex Riesen, Jul 21, 2008
  2. Johannes SchindelinJul 21, 2008
  3. Alex RiesenJul 21, 2008
  4. Johannes SchindelinJul 21, 2008
  5. Junio C HamanoJul 22, 2008
  6. Alex RiesenJul 22, 2008
  7. Johannes SixtJul 22, 2008
  8. Alex RiesenJul 22, 2008
  9. Johannes SixtJul 22, 2008
  10. Junio C HamanoJul 22, 2008
  11. Build configuration to skip ctime for modification testAlex Riesen, Jul 22, 2008
  12. Johannes SchindelinJul 22, 2008
  13. Alex RiesenJul 22, 2008
  14. Junio C HamanoJul 23, 2008
  15. Alex RiesenJul 23, 2008
  16. Johannes SchindelinJul 23, 2008
  17. Alex RiesenJul 23, 2008
  18. Linus TorvaldsJul 25, 2008
  19. Alex RiesenJul 25, 2008
  20. Johannes SchindelinJul 26, 2008
  21. Make use of stat.ctime configurableAlex Riesen, Jul 26, 2008
  22. Junio C HamanoJul 27, 2008
  23. Junio C HamanoJul 27, 2008
  24. Make use of stat.ctime configurableAlex Riesen, Jul 28, 2008
  25. David BrownJul 28, 2008
  26. Linus TorvaldsJul 28, 2008
  27. Alex RiesenJul 28, 2008
  28. Junio C HamanoJul 29, 2008
  29. Linus TorvaldsJul 29, 2008
  30. Junio C HamanoJul 29, 2008
  31. David BrownJul 29, 2008
  32. Junio C HamanoJul 29, 2008
  33. Johannes SchindelinJul 29, 2008
  34. Linus TorvaldsJul 29, 2008
  35. Linus TorvaldsJul 29, 2008
  36. Johannes SchindelinJul 29, 2008
  37. Petr BaudisJul 28, 2008
  38. Improve the placement of core.trustctime in the documentationAlex Riesen, Jul 28, 2008
  39. Junio C HamanoJul 29, 2008
  40. Do not use ctime if file mode is not usedAlex Riesen, Jul 24, 2008
  41. git svn throws locale related error when built from sourceAnton Mostovoy, Jul 23, 2008

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.