Git 2.2.x毫无理由地更新旧包文件的时间戳 [英] Git 2.2.x updates timestamps of old pack files for no good reason

查看:59
本文介绍了Git 2.2.x毫无理由地更新旧包文件的时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git 2.2.0和2.2.1似乎无缘无故地修改了旧的.git/objects/pack/pack-*.pack文件的时间戳.

Git 2.2.0 and 2.2.1 seem to modify the timestamps of old .git/objects/pack/pack-*.pack files occasionally, for no good reason.

它只是更改时间戳;内容是相同的.

It just changes the timestamp; the contents are identical.

调试它很困难,因为它似乎很少进行更改.

Debugging this is difficult as it seems to make changes only fairly rarely.

在2.2.0之前的任何Git版本中,我从未见过这样的事情.发生了什么事,我可以以某种方式解决它吗?由于无用的时间戳更新,我突然发现增量备份需要进行大量更改.

I have never seen anything like this in any Git version before 2.2.0. What is happening, and can I fix it somehow? Because of the useless timestamp updates I am getting suddenly large amounts of changes for incremental backups.

推荐答案

Git在磁盘上保留的信息比在存储库中记录所有信息绝对必要的信息更多.保留不必要的信息以加快某些操作和/或避免必须重写文件.决定何时删除一些不必要文件的算法将打包文件的修改时间作为决策过程的一部分(请参见find_lru_pack).因此,mtime由git中的类似缓存的机制使用.打包文件的修改时间在git中更改,而无需修改文件(请参见freshen_file函数),以帮助正确进行缓存并避免驱逐可能再次使用的文件.

Git keeps more information on disk than absolutely necessary to record all information in the repository. The unnecessary information is kept to accelerate certain operations and/or avoid having to rewrite files. The algorithm to decide when to delete some of the unnecessary files uses modification time of the pack files as part of the decision process (see find_lru_pack). Therefore mtime is used by a cache-like mechanism in git. Modification time of pack files is changed in git without modifying the file (see freshen_file function) in order to aid the correct caching and avoiding evicting files likely to be used again.

如果将sha1_file中的freshen_file修改为空操作,则不应修改mtimes.但是,如果正像垃圾回收一样,使用与以前相同的数据写入新的提交,这将使您有可能遭受数据丢失的困扰(感谢您在下面的评论中指出这一点).

If you modify freshen_file in sha1_file to a no-operation then mtimes should not be ever modified. This will however leave you open to potential data loss if there is a new commit being written with same data as before just as a garbage collection happens (thanks to comment below for pointing this out).

这篇关于Git 2.2.x毫无理由地更新旧包文件的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆