As we also hold a mutable borrow to the refs. Fair enough.
Showing the changes to git-protocol/src/fetch/function.rs (1 of 10 files). Show all
Unified · Split
| @@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | use git_features::{progress, progress::Progress}; |
| 6 | 6 | use git_transport::{ |
| 7 | 7 | client, |
| 8 | − client::{SetServiceResponse, TransportV2Ext}, | |
| 8 | + client::{ProtocolDecision, SetServiceResponse, TransportV2Ext}, | |
| 9 | 9 | Service, |
| 10 | 10 | }; |
| 11 | 11 | use maybe_async::maybe_async; |
| @@ -71,6 +71,17 @@ where · 59 unmodified lines | ||
| 71 | 71 | Err(err) => Err(err), |
| 72 | 72 | }?; |
| 73 | 73 | |
| 74 | + match transport.supports_advertised_version(actual_protocol) { | |
| 75 | + ProtocolDecision::Continue => {} | |
| 76 | + ProtocolDecision::CloseConnectionImmediately => { | |
| 77 | + drop(refs); | |
| 78 | + transport.close().await; | |
| 79 | + return Err((Error::TransportProtocolPolicyViolation { | |
| 80 | + actual_version: actual_protocol, | |
| 81 | + })); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 74 | 85 | let parsed_refs = match refs { |
| 75 | 86 | Some(mut refs) => { |
| 76 | 87 | assert_eq!( |
| @@ -88,14 +99,6 @@ where · 11 unmodified lines | ||
| 88 | 99 | (actual_protocol, parsed_refs, capabilities) |
| 89 | 100 | }; // this scope is needed, see https://github.com/rust-lang/rust/issues/76149 |
| 90 | 101 | |
| 91 | − if transport.desired_protocol_version() != protocol_version { | |
| 92 | − progress.info(format!( | |
| 93 | − "server did not support protocol {} and downgraded to {}", | |
| 94 | − transport.desired_protocol_version() as usize, | |
| 95 | − protocol_version as usize, | |
| 96 | − )); | |
| 97 | − } | |
| 98 | − | |
| 99 | 102 | let parsed_refs = match parsed_refs { |
| 100 | 103 | Some(refs) => refs, |
| 101 | 104 | None => { |