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

Add bindings for mwindow opts #1035

Merged
merged 3 commits into from
Mar 18, 2024
Merged

Conversation

rpelliard
Copy link
Contributor

@rpelliard rpelliard commented Mar 11, 2024

This adds bindings for the mwindow options (https://libgit2.org/libgit2/#HEAD/group/libgit2/git_libgit2_opts)

This will avoid calling libgit2-sys directly to set these options, see related issues where this would be useful:

@ehuss
Copy link
Contributor

ehuss commented Mar 11, 2024

Thanks for the PR! I'm a little uncertain about using usize for these values since they are defined as size_t in libgit2. I think there is still some uncertainty if usize should always be the same as size_t (see rust-lang/rust#88345). Perhaps to be on the safe side, they should be defined as size_t?

@rpelliard
Copy link
Contributor Author

@ehuss Happy to do that change ! Just to make sure I understand correctly, do you suggest casting the usize to libc::size_t (or core::ffi::size_t?) before passing it to libgit2, or completely changing the param/return types of the public interface to stop using usize completely ?

@ehuss
Copy link
Contributor

ehuss commented Mar 13, 2024

Good question. I would probably just change the types of the function signatures to be libc::size_t. Since it is a type alias, it probably won't matter much, and I believe will allow the caller to use usize values without any issues.

It is a bit unfortunate that the usize↔size_t relationship isn't clearer. Being a type alias (and not a newtype wrapper) makes it even more ambiguous.

@rpelliard
Copy link
Contributor Author

Makes sense, I pushed an update to use libc::size_t as parameter and return type

@ehuss
Copy link
Contributor

ehuss commented Mar 16, 2024

Thanks! One more thing, I'm pretty sure these need to be unsafe. There is no synchronization in modifying these values, so they should only be done on the main thread before any threads are spawned. (At least, that is my understanding. Interaction with C globals seems like a dark art.)

@rpelliard
Copy link
Contributor Author

Good point, done !

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!

@ehuss ehuss added this pull request to the merge queue Mar 18, 2024
Merged via the queue into rust-lang:master with commit 3778952 Mar 18, 2024
7 checks passed
@rpelliard rpelliard deleted the mwindow-opts branch March 18, 2024 16:13
@rpelliard rpelliard mentioned this pull request Mar 18, 2024
@rpelliard
Copy link
Contributor Author

@ehuss Thanks ! Would you be open to a release containing these changes ? I prepared #1036

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.

2 participants