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

Re: git bugs

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2008, 23:38 UTC
Message-ID
<7v1w34dfn3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<832adb090806101609q17a21948nb5814c3b22bd832d@mail.gmail.com>
"Ben Lynn" <benlynn@gmail.com> writes:
> I had thought about this. I hacked some code up where the index looks
> at the current system time when updating a cache entry to determine if
> the hash is racy. Is doing one time(NULL) call per file reasonable?
> I'm guessing it must be cheaper that a stat call.

Hmm, sorry, could you elaborate how you would plan to use the return value from time(2) per file?

The "index file timestamp" trick assumes that once we start reading from and writing to the filesystem (in order to hash the current contents, check if there is any modification), nobody else touches the paths we are interested in (e.g., after "read-tree -m -u" checks out the new contents, grabs the stat information from the newly deposited file and stuffs that in the index, you do not go in and edit it further until our process returns the control to you). We also assume that the files (both work tree and the index) live in the same filesystem and the file timestamp, which could be skewed compared to the system clock if the filesystem is over the network, are consistent among them and monotonicly increasing.

        You have to have some assumption --- if you allow anybody to touch
        anything behind your back, or if you allow timestamps of some
        files come from different time sources than the one for some other
        files, I do not think any lstat(2) based change detection scheme
        would work.

We do our writeout first and then the index is updated after all our writeout is done, so by definition (more precisely, "by that assumption"), anything older than the timestamp of the index file are up to date, if their filesystem timestamp match the timestamp recorded in the index, and anything that is the same or newer than the index timestamp is suspect.

And that is the reason the current code gets by only with a single timestamp. I'd have to go back and study your breakage scenario a bit better (I'm still at work today).

Previous: Ben LynnNext: Ben Lynn
Message 7 of 35 in “git bugs”
  1. Ben LynnJun 10, 2008
  2. Daniel BarkalowJun 10, 2008
  3. Linus TorvaldsJun 10, 2008
  4. Ben LynnJun 10, 2008
  5. Linus TorvaldsJun 10, 2008
  6. Ben LynnJun 10, 2008
  7. Junio C HamanoJun 10, 2008
  8. Ben LynnJun 11, 2008
  9. Junio C HamanoJun 11, 2008
  10. Ben LynnJun 11, 2008
  11. Ben LynnJun 11, 2008
  12. Stephen R. van den BergJun 11, 2008
  13. Ben LynnJun 12, 2008
  14. Linus TorvaldsJun 11, 2008
  15. Ben LynnJun 11, 2008
  16. Linus TorvaldsJun 11, 2008
  17. Ben LynnJun 11, 2008
  18. Linus TorvaldsJun 11, 2008
  19. Ben LynnJun 11, 2008
  20. Ben LynnJun 11, 2008
  21. Linus TorvaldsJun 11, 2008
  22. Ben LynnJun 11, 2008
  23. Linus TorvaldsJun 11, 2008
  24. Ben LynnJun 11, 2008
  25. Linus TorvaldsJun 11, 2008
  26. Ben LynnJun 11, 2008
  27. Junio C HamanoJun 11, 2008
  28. Linus TorvaldsJun 11, 2008
  29. Junio C HamanoJun 12, 2008
  30. Jeff KingJun 13, 2008
  31. Junio C HamanoJun 13, 2008
  32. Jeff KingJun 14, 2008
  33. Shawn O. PearceJun 12, 2008
  34. Ben LynnJun 12, 2008
  35. Johannes SchindelinJun 12, 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.