问题描述
git如何快速检测文件修改?
它是否对散列表中的每个文件进行散列并比较SHA1?这会花费很多时间,不是吗?
或者它比较 atime
, ctime
或 mtime
?
Git很难从lstat()值中唯一确信工作树匹配索引,因为回退文件内容非常昂贵。
描述什么样的统计字段被使用,以及如何避免由于低时间粒度造成的一些竞争条件。 。
值不是防篡改的,参见futimens(3)。 Git可能会被愚弄到丢失对文件的更改;这不会影响内容散列的完整性。
How does git detect a file modification so fast?
Does it hash every file in the repo and compare SHA1s? This would take a lot of time, wouldn't it?
Or does it compare atime
, ctime
or mtime
?
Git tries hard to get convinced from the lstat() value alone that the worktree matches the index, because falling back on file contents is very expensive.
Documentation/technical/racy-git.txt describes what stat fields are used, and how some race conditions due to low mtime granularity are avoided. This article has some more detail.
stat values aren't tamper-proof, see futimens(3). Git may be fooled into missing a change to a file; that does not compromise the integrity of content-hashing.
这篇关于git如何检测文件已被修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!