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, [])
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?