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
libgit2: Bump to v1.8.0 #1032
base: master
Are you sure you want to change the base?
libgit2: Bump to v1.8.0 #1032
Conversation
This commit changes the original `ssh` feature into two new ones: `ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` feature is enabled for backwards compatibility. To use OpenSSH instead, the following listing in `Cargo.toml` can be used: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] } This commit is stacked on top of rust-lang#1032, and should only be merged after libgit2 v1.8.0 has been released. Closes rust-lang#1028.
This commit changes the original `ssh` feature into two new ones: `ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` feature is enabled for backwards compatibility. To use OpenSSH instead, the following listing in `Cargo.toml` can be used: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] } This commit is stacked on top of rust-lang#1032, and should only be merged after libgit2 v1.8.0 has been released. Closes rust-lang#1028.
Looks like the current test failures are due to changes made in libgit2/libgit2#6743 👀 |
This commit changes the original `ssh` feature into two new ones: `ssh-libssh2` and `ssh-openssh`. By default, the `ssh-libssh2` feature is enabled for backwards compatibility. To use OpenSSH instead, the following listing in `Cargo.toml` can be used: git2-rs = { version = "...", default-features = false, features = ["https", "ssh-openssh"] } This commit is stacked on top of rust-lang#1032, and should only be merged after libgit2 v1.8.0 has been released. Closes rust-lang#1028.
f4549ca
to
7d0742e
Compare
Looks like v1.8.0 is out! I will update the PR to bump the version. |
7d0742e
to
619fc02
Compare
619fc02
to
67a64a1
Compare
67a64a1
to
3c4b106
Compare
This should be ready for review. (I'm pretty new to Rust and the The test failures on Windows are related to libgit2/libgit2#6743 as mentioned above—I'm not too sure how to handle these conventionally using Rust. |
@@ -391,7 +402,7 @@ pub struct git_fetch_options { | |||
pub version: c_int, | |||
pub callbacks: git_remote_callbacks, | |||
pub prune: git_fetch_prune_t, | |||
pub update_fetchhead: c_int, | |||
pub update_flags: c_uint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm not really confident this is the correct way to handle packed bitflags. I had the understanding that Rust doesn't really support packed bitflags, at least in a compatible way with C, since it depends on the compiler. Do you have some more information on why this might be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I wasn't familiar with C bitfields, I originally thought they were just a convenient way of specifying bit-flags which are handled in a similar way to bitmasks for unsigned ints. It does seem hard to support since their memory layout is compiler dependent. I was thinking since we know the number of bits set, assuming that bits are packed only either left-to-right or right-to-left, we could do something like update_flag.bits() | update_flag.bits().reverse_bits()
when getting the unsigned int as a workaround? (This admittedly doesn't work if the memory layout is different.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehuss whats the way to interact with c bitfields via FFI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no official support for C bitfields in Rust: rust-lang/rfcs#314.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no good way to use bitfields from Rust's FFI, and that won't be fixed in a timeframe reasonable for updating this library, so I suggest hacking around it.
This field will have a correct size — the C header explicitly specifies it as unsigned int
, so the risk of problems seems relatively low. In the worst case these options won't be set, but that's just an application-level nuisance, not memory corruption.
AFAIK C treats unused bits as padding, so update_flag.bits() | update_flag.bits().reverse_bits()
should be safe.
If that's still too risky, then the correct way to deal with this would be to compile and link a C file that exports Rust-FFI-compatible getter and setter functions for these fields. Perhaps do that only when building the library from vendored source to avoid pains of with finding correct headers and ensuring they actually match .so lib's ABI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I haven't had much time lately. I've been intending to push a change that will use a C wrapper to get/set the fields, I just haven't gotten to it, yet. I don't feel comfortable trying to guess the layout from within Rust. @bnjmnt4n If you have time to give that a shot, that would be helpful. Otherwise, I'll try to look into it soonish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehuss @bnjmnt4n The maintainer of libgit2 said he can guarantee the ABI will use least significant bits for the flags: libgit2/libgit2#6800
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status update: ethomson mentioned in libgit2/libgit2#6800 that they will look to see if there is some workaround for us.
Hm, that's awkward. I don't really understand why TempDir is returning short path. One option is to |
44e8b35
to
bb75668
Compare
…ialized properly
FYI, this blocks the upgrade of libgit2 to 1.8.0 in Alpine Linux (!63296). |
Is this PR still blocked? |
This PR bumps
libgit2
to v1.8.0, in preparation for #1031. I've bumpedlibgit2-sys
to0.17.0+1.8.0
, but haven't touched thegit2
version since I thought that's better left for the maintainers.I haven't included any new Rust bindings for the new functions (e.g.
git_commit_create_from_stage
). Basically I've just done the bare minimum required to get thelibgit2
v1.8.0 working.API changes:
Remote
:update_tips
now accepts aRemoteUpdateFlags
which is an integer consisting of bitfields instead of a booleanFetchOptions
: addreport_unchanged
method which updates theupdate_flags
bitflag (similar to above)PushOptions
: addremote_push_options
method to set remote push optionsWorktreeAddOptions
: addcheckout_existing
method to set the booleancheckout_existing
optionReferences