Add bindings for cache size options#1188
Merged
Merged
Conversation
ehuss
reviewed
Oct 6, 2025
| /// # Safety | ||
| /// This function is modifying a C global without synchronization, so it is not | ||
| /// thread safe, and should only be called before any thread is spawned. | ||
| pub unsafe fn set_cache_max_size(size: libc::size_t) -> Result<(), Error> { |
Contributor
There was a problem hiding this comment.
Shouldn't all of these values be ssize_t (two s's)?
Not that it makes a huge difference, and it's not clear why it is signed, but probably best to match upstream, no?
Contributor
Author
There was a problem hiding this comment.
Totally, I missed this ! Thanks for catching
Contributor
|
Can you also add a test for this? |
ehuss
approved these changes
Oct 7, 2025
Contributor
ehuss
left a comment
There was a problem hiding this comment.
Thanks!
(And I realize the tests themselves aren't honoring the safety invariants, but I think are mostly ok for that purpose.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two simple bindings to interact with the ODB cache:
GIT_OPT_SET_CACHE_MAX_SIZEto update the cache max sizeGIT_OPT_GET_CACHED_MEMORYto retrieve current and max cache sizeSee relevant libgit2 docs here.