Skip to content

Commit b6506a4

Browse files
committed
[ref-ls] Make things compile
Looks like none fo the transports aer working yet :D. Unexpected input and handling. Now it's about beefing up debugging capabilities.
1 parent 4ba50fe commit b6506a4

File tree

6 files changed

+51
-12
lines changed

6 files changed

+51
-12
lines changed

git-transport/src/client/connect.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,41 @@ quick_error! {
2828
}
2929
}
3030

31+
/// Would be so nice if this wasn't necessary
32+
mod box_impl {
33+
use crate::{
34+
client::{self, Error, Identity, MessageKind, RequestWriter, SetServiceResponse, WriteMode},
35+
Protocol, Service,
36+
};
37+
use std::ops::{Deref, DerefMut};
38+
39+
impl client::Transport for Box<dyn client::Transport> {
40+
fn handshake(&mut self, service: Service) -> Result<SetServiceResponse, Error> {
41+
self.deref_mut().handshake(service)
42+
}
43+
44+
fn set_identity(&mut self, identity: Identity) -> Result<(), Error> {
45+
self.deref_mut().set_identity(identity)
46+
}
47+
48+
fn request(&mut self, write_mode: WriteMode, on_drop: Vec<MessageKind>) -> Result<RequestWriter, Error> {
49+
self.deref_mut().request(write_mode, on_drop)
50+
}
51+
52+
fn close(&mut self) -> Result<(), Error> {
53+
self.deref_mut().close()
54+
}
55+
56+
fn to_url(&self) -> String {
57+
self.deref().to_url()
58+
}
59+
60+
fn desired_protocol_version(&self) -> Protocol {
61+
self.deref().desired_protocol_version()
62+
}
63+
}
64+
}
65+
3166
/// A general purpose connector with just the default configuration.
3267
pub fn connect(url: &[u8], version: crate::Protocol) -> Result<Box<dyn Transport>, Error> {
3368
let urlb = url;

git-transport/src/client/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl client::Transport for SpawnProcessOnDemand {
121121
.request(write_mode, on_drop)
122122
}
123123

124-
fn close(mut self) -> Result<(), client::Error> {
125-
if let Some(c) = self.connection.take() {
124+
fn close(&mut self) -> Result<(), client::Error> {
125+
if let Some(mut c) = self.connection.take() {
126126
c.close()
127127
} else {
128128
Ok(())

git-transport/src/client/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ where
103103
))
104104
}
105105

106-
fn close(mut self) -> Result<(), client::Error> {
106+
fn close(&mut self) -> Result<(), client::Error> {
107107
if self.actual_version == Protocol::V2 {
108108
git_packetline::encode::flush_to_write(&mut self.writer)?;
109109
self.writer.flush()?;

git-transport/src/client/http/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<H: Http> client::Transport for Transport<H> {
173173
))
174174
}
175175

176-
fn close(self) -> Result<(), client::Error> {
176+
fn close(&mut self) -> Result<(), client::Error> {
177177
Ok(())
178178
}
179179

git-transport/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub trait Transport {
214214
fn request(&mut self, write_mode: WriteMode, on_drop: Vec<MessageKind>) -> Result<RequestWriter, Error>;
215215

216216
/// Closes the connection to indicate no further requests will be made.
217-
fn close(self) -> Result<(), Error>;
217+
fn close(&mut self) -> Result<(), Error>;
218218

219219
/// Returns the canonical URL pointing to the destination of this transport.
220220
/// Please note that local paths may not be represented correctly, as they will go through a potentially lossy

gitoxide-core/src/remote.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod refs {
4242
<P as Progress>::SubProgress: Send + 'static,
4343
<<P as Progress>::SubProgress as Progress>::SubProgress: Send,
4444
{
45-
let mut transport = git_transport::client::connect(url.as_bytes(), protocol.unwrap_or_default().into())?;
45+
let transport = git_transport::client::connect(url.as_bytes(), protocol.unwrap_or_default().into())?;
4646
let mut delegate = LsRemotes::default();
4747
git_protocol::fetch(transport, &mut delegate, git_protocol::credentials::helper, progress)?;
4848

@@ -54,16 +54,20 @@ pub mod refs {
5454
Ok(())
5555
}
5656

57-
fn print(out: impl io::Write, refs: &[Ref]) -> io::Result<()> {
57+
fn print(mut out: impl io::Write, refs: &[Ref]) -> io::Result<()> {
5858
for r in refs {
5959
match r {
60-
Ref::Direct { path, object } => writeln!(out, "{} {}", object.to_sha1_hex_string(), path),
60+
Ref::Direct { path, object } => writeln!(&mut out, "{} {}", object.to_sha1_hex_string(), path),
6161
Ref::Peeled { path, object, tag } => {
62-
writeln!(out, "{} {} tag:{}", object.to_sha1_hex_string(), path, tag)
63-
}
64-
Ref::Symbolic { path, target, object } => {
65-
writeln!(out, "{} {} symref-target:{}", object.to_sha1_hex_string(), path, target)
62+
writeln!(&mut out, "{} {} tag:{}", object.to_sha1_hex_string(), path, tag)
6663
}
64+
Ref::Symbolic { path, target, object } => writeln!(
65+
&mut out,
66+
"{} {} symref-target:{}",
67+
object.to_sha1_hex_string(),
68+
path,
69+
target
70+
),
6771
Ref::SymbolicForLookup { .. } => unreachable!("Bug: these should be resolved already"),
6872
}?;
6973
}

0 commit comments

Comments
 (0)