History

[transport] flexible version of version support check doesn't actually work :D

As we also hold a mutable borrow to the refs. Fair enough.

Sebastian Thiel committed 5 years ago

Commit 2b220f01 parent 22f7e6710 files · +89 −28Browse files

Showing the changes to git-protocol/src/fetch/function.rs (1 of 10 files). Show all

Unified · Split

git-protocol/src/fetch/function.rs+12−9
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
5use git_features::{progress, progress::Progress};5use git_features::{progress, progress::Progress};
6use git_transport::{6use git_transport::{
7 client,7 client,
8 client::{SetServiceResponse, TransportV2Ext},8 client::{ProtocolDecision, SetServiceResponse, TransportV2Ext},
9 Service,9 Service,
10};10};
11use maybe_async::maybe_async;11use maybe_async::maybe_async;
@@ -71,6 +71,17 @@ where · 59 unmodified lines
71 Err(err) => Err(err),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 let parsed_refs = match refs {85 let parsed_refs = match refs {
75 Some(mut refs) => {86 Some(mut refs) => {
76 assert_eq!(87 assert_eq!(
@@ -88,14 +99,6 @@ where · 11 unmodified lines
88 (actual_protocol, parsed_refs, capabilities)99 (actual_protocol, parsed_refs, capabilities)
89 }; // this scope is needed, see https://github.com/rust-lang/rust/issues/76149100 }; // 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 let parsed_refs = match parsed_refs {102 let parsed_refs = match parsed_refs {
100 Some(refs) => refs,103 Some(refs) => refs,
101 None => {104 None => {