From 28a50184c98368647300d9b7a988d3ea5216a34f Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 12 Apr 2024 20:59:35 +0000 Subject: [PATCH] Use `Url::host_as_argument()` in `ssh::connect()` Instead of `Url::host_argument_safe()`. This also removes the comment about how the username should be handled if added, mostly because I didn't really need to add that comment. --- gix-transport/src/client/blocking_io/ssh/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gix-transport/src/client/blocking_io/ssh/mod.rs b/gix-transport/src/client/blocking_io/ssh/mod.rs index 7d179951f6..6820051a5e 100644 --- a/gix-transport/src/client/blocking_io/ssh/mod.rs +++ b/gix-transport/src/client/blocking_io/ssh/mod.rs @@ -1,5 +1,7 @@ use std::process::Stdio; +use gix_url::ArgumentSafety::*; + use crate::{client::blocking_io, Protocol}; /// The error used in [`connect()`]. @@ -118,11 +120,11 @@ pub fn connect( .stdin(Stdio::null()) .with_shell() .arg("-G") - // Username affects the stdout from `ssh -G` but may not affect the status. But if - // we end up needing it, it can be added here, with a user_argument_safe() check. - .arg(url.host_argument_safe().ok_or_else(|| Error::AmbiguousHostName { - host: url.host().expect("set in ssh urls").into(), - })?), + .arg(match url.host_as_argument() { + Usable(host) => host, + Dangerous(host) => Err(Error::AmbiguousHostName { host: host.into() })?, + Absent => panic!("BUG: host should always be present in SSH URLs"), + }), ); gix_features::trace::debug!(cmd = ?cmd, "invoking `ssh` for feature check"); kind = if cmd.status().ok().map_or(false, |status| status.success()) {