Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save index with "cache tree" extension? #1207

Open
sergey-komissarov opened this issue Mar 31, 2023 · 0 comments
Open

How to save index with "cache tree" extension? #1207

sergey-komissarov opened this issue Mar 31, 2023 · 0 comments

Comments

@sergey-komissarov
Copy link

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, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant