diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix/src/config/tree/sections/ssh.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/config/tree/sections/ssh.rs')
-rw-r--r-- | vendor/gix/src/config/tree/sections/ssh.rs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/vendor/gix/src/config/tree/sections/ssh.rs b/vendor/gix/src/config/tree/sections/ssh.rs new file mode 100644 index 000000000..600ee663b --- /dev/null +++ b/vendor/gix/src/config/tree/sections/ssh.rs @@ -0,0 +1,65 @@ +use crate::{ + config, + config::tree::{keys, Key, Section, Ssh}, +}; + +impl Ssh { + /// The `ssh.variant` key + pub const VARIANT: Variant = Variant::new_with_validate("variant", &config::Tree::SSH, validate::Variant) + .with_environment_override("GIT_SSH_VARIANT") + .with_deviation("We error if a variant is chosen that we don't know, as opposed to defaulting to 'ssh'"); +} + +/// The `ssh.variant` key. +pub type Variant = keys::Any<validate::Variant>; + +#[cfg(feature = "blocking-network-client")] +mod variant { + use std::borrow::Cow; + + use crate::{bstr::BStr, config, config::tree::ssh::Variant}; + + impl Variant { + pub fn try_into_variant( + &'static self, + value: Cow<'_, BStr>, + ) -> Result<Option<gix_protocol::transport::client::ssh::ProgramKind>, config::key::GenericErrorWithValue> + { + use gix_protocol::transport::client::ssh::ProgramKind; + + use crate::bstr::ByteSlice; + Ok(Some(match value.as_ref().as_bytes() { + b"auto" => return Ok(None), + b"ssh" => ProgramKind::Ssh, + b"plink" => ProgramKind::Plink, + b"putty" => ProgramKind::Putty, + b"tortoiseplink" => ProgramKind::TortoisePlink, + b"simple" => ProgramKind::Simple, + _ => return Err(config::key::GenericErrorWithValue::from_value(self, value.into_owned())), + })) + } + } +} + +impl Section for Ssh { + fn name(&self) -> &str { + "ssh" + } + + fn keys(&self) -> &[&dyn Key] { + &[&Self::VARIANT] + } +} + +mod validate { + use crate::{bstr::BStr, config::tree::keys}; + + pub struct Variant; + impl keys::Validate for Variant { + fn validate(&self, _value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> { + #[cfg(feature = "blocking-network-client")] + super::Ssh::VARIANT.try_into_variant(_value.into())?; + Ok(()) + } + } +} |