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

libgit2: Add support for OpenSSH instead of libssh2 #1031

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

bnjmnt4n
Copy link

@bnjmnt4n bnjmnt4n commented Mar 1, 2024

This PR 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 PR is stacked on top of #1032.

Closes #1028.

@bnjmnt4n
Copy link
Author

bnjmnt4n commented Mar 1, 2024

Hmm, let me try to see if I can figure out why the tests are failing...

@Nemo157
Copy link
Member

Nemo157 commented Mar 13, 2024

One issue I've noticed with this is when linking against a system library it doesn't detect whether it was compiled with openssh enabled, so the feature only really works when forcing the vendored library.

(EDIT: Well, also it shouldn't be allowing the system library since it's only 1.7.2, the 1.8.0 bump needs to update the pkg-config version range too).

@bnjmnt4n
Copy link
Author

I can update the version range detected, but I'm not too sure how to proceed with detecting which version of the SSH backend libgit2 was compiled with, would appreciate some guidance on that.

@bnjmnt4n bnjmnt4n marked this pull request as draft March 22, 2024 12:41
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"] }
// HACK: `libgit2` uses C bitfields, which do not have a guaranteed memory layout.
// Reversing the bits ensures that the bitfields are set whether the bits are laid out
// from left to right or right to left, but will not work on other memory layouts.
update_flags: (self.update_flags.bits() | self.update_flags.bits().reverse_bits())
Copy link
Contributor

Choose a reason for hiding this comment

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

did you check whether this will make the reverse overlap with another meaningful bit?

Copy link
Author

Choose a reason for hiding this comment

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

The number of meaningful bits is currently 2, so there will be no overlay (2 at each end, with 4 bits in the middle unused for the 8 bits of an unsigned int). However, this might be an issue if more bits in the flag are used.

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.

support building USE_SSH=exec
3 participants