git如何检测文件已被修改?

编程入门 行业动态 更新时间:2024-10-19 19:29:54
本文介绍了git如何检测文件已被修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

git如何快速检测文件修改?

它是否对散列表中的每个文件进行散列并比较SHA1?这会花费很多时间,不是吗?

或者它比较 atime , ctime 或 mtime ?

解决方案

Git很难从lstat()值中唯一确信工作树匹配索引,因为回退文件内容非常昂贵。

Documentation / technical / racy-git.txt 描述什么样的统计字段被使用,以及如何避免由于低时间粒度造成的一些竞争条件。 这篇文章有更多的细节。

值不是防篡改的,参见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如何检测文件已被修改?

本文发布于:2023-11-27 09:14:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637458.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:已被   文件   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!