Skip to content

Conversation

rpelliard
Copy link
Contributor

@rpelliard rpelliard commented Oct 6, 2025

This PR adds two simple bindings to interact with the ODB cache:

  • GIT_OPT_SET_CACHE_MAX_SIZE to update the cache max size
  • GIT_OPT_GET_CACHED_MEMORY to retrieve current and max cache size

See relevant libgit2 docs here.

@rpelliard rpelliard marked this pull request as ready for review October 6, 2025 05:21
@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Oct 6, 2025
src/opts.rs Outdated
/// # 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> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally, I missed this ! Thanks for catching

@ehuss
Copy link
Contributor

ehuss commented Oct 6, 2025

Can you also add a test for this?

@rpelliard rpelliard requested a review from ehuss October 6, 2025 18:20
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

(And I realize the tests themselves aren't honoring the safety invariants, but I think are mostly ok for that purpose.)

@ehuss ehuss added this pull request to the merge queue Oct 7, 2025
Merged via the queue into rust-lang:master with commit 1d9f4d4 Oct 7, 2025
7 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting on review label Oct 7, 2025
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

Successfully merging this pull request may close these issues.

3 participants