feat: add Repository::refdb_compress() for packing loose refs#1221
Conversation
90fdb8a to
e8dd7d5
Compare
| assert!(repo.references_glob("refs/tags/test-*").unwrap().count() == 20); | ||
|
|
||
| // Compress should pack them without error. | ||
| repo.refdb_compress().unwrap(); |
There was a problem hiding this comment.
Would it make sense to check the file packed-refs does not exist before calling this, and then check that it is created afterwards?
There was a problem hiding this comment.
Thanks for that - good shout.
I've added a check for that.
There was a problem hiding this comment.
Thanks!
As a longer-term alternative, another consideration would be to have a separate Rust type for a refdb and have compress be a method on it. However, since compress is currently the only thing you can do with it, it seems fine to have a convenience method for it on Repository.
|
@ehuss thanks for taking a look at this and providing a review Was a very positive and easy experience Happy to noodle on that idea you had |
Wraps libgit2's
git_refdb_compress()as a safe Rust method on Repository.Link: https://libgit2.org/docs/reference/main/refdb/git_refdb_compress.html
Motivation:
Repositories with many loose refs (e.g. thousands of tags or identity refs) suffer degraded fetch and clone performance.
This exposes libgit2's ref packing capability so callers can compact loose refs into packed-refs without shelling out to git.