summaryrefslogtreecommitdiffstats
path: root/vendor/gix-protocol/src/handshake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/gix-protocol/src/handshake
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-protocol/src/handshake')
-rw-r--r--vendor/gix-protocol/src/handshake/function.rs2
-rw-r--r--vendor/gix-protocol/src/handshake/mod.rs6
-rw-r--r--vendor/gix-protocol/src/handshake/refs/tests.rs27
3 files changed, 32 insertions, 3 deletions
diff --git a/vendor/gix-protocol/src/handshake/function.rs b/vendor/gix-protocol/src/handshake/function.rs
index c56824cca..1206ee363 100644
--- a/vendor/gix-protocol/src/handshake/function.rs
+++ b/vendor/gix-protocol/src/handshake/function.rs
@@ -46,7 +46,7 @@ where
progress.set_name("authentication");
let credentials::protocol::Outcome { identity, next } =
authenticate(credentials::helper::Action::get_for_url(url.clone()))?
- .expect("FILL provides an identity or errors");
+ .ok_or(Error::EmptyCredentials)?;
transport.set_identity(identity)?;
progress.step();
progress.set_name("handshake (authenticated)");
diff --git a/vendor/gix-protocol/src/handshake/mod.rs b/vendor/gix-protocol/src/handshake/mod.rs
index 4e0741012..6d70ed145 100644
--- a/vendor/gix-protocol/src/handshake/mod.rs
+++ b/vendor/gix-protocol/src/handshake/mod.rs
@@ -3,7 +3,7 @@ use gix_transport::client::Capabilities;
/// A git reference, commonly referred to as 'ref', as returned by a git server before sending a pack.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
-#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Ref {
/// A ref pointing to a `tag` object, which in turns points to an `object`, usually a commit
Peeled {
@@ -46,7 +46,7 @@ pub enum Ref {
/// The result of the [`handshake()`][super::handshake()] function.
#[derive(Default, Debug, Clone)]
-#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Outcome {
/// The protocol version the server responded with. It might have downgraded the desired version.
pub server_protocol_version: gix_transport::Protocol,
@@ -68,6 +68,8 @@ mod error {
pub enum Error {
#[error("Failed to obtain credentials")]
Credentials(#[from] credentials::protocol::Error),
+ #[error("No credentials were returned at all as if the credential helper isn't functioning unknowingly")]
+ EmptyCredentials,
#[error("Credentials provided for \"{url}\" were not accepted by the remote")]
InvalidCredentials { url: BString, source: std::io::Error },
#[error(transparent)]
diff --git a/vendor/gix-protocol/src/handshake/refs/tests.rs b/vendor/gix-protocol/src/handshake/refs/tests.rs
index a7c9171a5..7d995da5c 100644
--- a/vendor/gix-protocol/src/handshake/refs/tests.rs
+++ b/vendor/gix-protocol/src/handshake/refs/tests.rs
@@ -170,6 +170,20 @@ impl<'a> gix_transport::client::ReadlineBufRead for Fixture<'a> {
self.0 = lines.as_bytes();
Some(Ok(Ok(gix_packetline::PacketLineRef::Data(res))))
}
+
+ fn readline_str(&mut self, line: &mut String) -> std::io::Result<usize> {
+ use bstr::{BStr, ByteSlice};
+ let bytes: &BStr = self.0.into();
+ let mut lines = bytes.lines();
+ let res = match lines.next() {
+ None => return Ok(0),
+ Some(line) => line,
+ };
+ self.0 = lines.as_bytes();
+ let len = res.len();
+ line.push_str(res.to_str().expect("valid UTF8 in fixture"));
+ Ok(len)
+ }
}
#[cfg(feature = "async-client")]
@@ -220,4 +234,17 @@ impl<'a> gix_transport::client::ReadlineBufRead for Fixture<'a> {
self.0 = lines.as_bytes();
Some(Ok(Ok(gix_packetline::PacketLineRef::Data(res))))
}
+ async fn readline_str(&mut self, line: &mut String) -> std::io::Result<usize> {
+ use bstr::{BStr, ByteSlice};
+ let bytes: &BStr = self.0.into();
+ let mut lines = bytes.lines();
+ let res = match lines.next() {
+ None => return Ok(0),
+ Some(line) => line,
+ };
+ self.0 = lines.as_bytes();
+ let len = res.len();
+ line.push_str(res.to_str().expect("valid UTF8 in fixture"));
+ Ok(len)
+ }
}