How to save index with "cache tree" extension?
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 408
- 平均合并
- 2 天 57 分钟
- 30 天内合并 PR
- 7
描述
Hello,
I have a project with approx 2000 files stored on NFS partition. When I initialize repository with pygit2 all subsequent commits took about 5sec. But after I commit anything (even empty tree) via git subsequent commits via pygit2 took only 0.5sec. This is because commit via git writes cache tree (https://git-scm.com/docs/index-format#_cache_tree) extension to .git/index file.
Finally I found that reading tree back to the index builds internal "cache tree". And now I wondering if this is a correct way to buid cache tree on initial commit?
repo = pygit2.init_repository(path, bare=False, flags=pygit2.GIT_REPOSITORY_INIT_NO_REINIT)
index = repo.index
index.add_all()
tree_id = index.write_tree()
# NOTE: Adds "cache tree" extension to the index.
index.read_tree(tree_id)
index.write()
repo.create_commit("HEAD", SIGNATURE, SIGNATURE, "Inital commit", tree_id, [])
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从 issue 中展示的 pygit2.init_repository、index.add_all()、index.write_tree()、index.read_tree()、index.write() 和 repo.create_commit() 调用开始,然后检查 index extensions 的处理方式。将生成的 index 与 git 在包含许多文件的 repository 中生成的 index 进行比较。完成标准是确定是否支持 cache tree,并记录或修正 initial-commit 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- git, python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100