History

adapt to changes in `gix-protocol`

Sebastian Thiel committed 1 year ago

Commit 25b84801 parent 59509263 files · +25 −5Browse files

Unified · Split

3 files
  1. gitoxide-core/src/pack/receive.rs +0 −2
  2. gix/src/remote/connection/fetch/error.rs +5 −0
  3. gix/src/remote/connection/fetch/receive_pack.rs +20 −3
gitoxide-core/src/pack/receive.rs+0−2
@@ -94,7 +94,6 @@ where · 93 unmodified lines
94 .await?;94 .await?;
95 let mut negotiate = Negotiate { refmap: &refmap };95 let mut negotiate = Negotiate { refmap: &refmap };
96 gix::protocol::fetch(96 gix::protocol::fetch(
97 &refmap,
98 &mut negotiate,97 &mut negotiate,
99 |read_pack, progress, should_interrupt| {98 |read_pack, progress, should_interrupt| {
100 receive_pack_blocking(99 receive_pack_blocking(
@@ -123,7 +122,6 @@ where · 22 unmodified lines
123 shallow_file: "no shallow file required as we reject it to keep it simple".into(),122 shallow_file: "no shallow file required as we reject it to keep it simple".into(),
124 shallow: &Default::default(),123 shallow: &Default::default(),
125 tags: Default::default(),124 tags: Default::default(),
126 expected_object_hash: Default::default(),
127 reject_shallow_remote: true,125 reject_shallow_remote: true,
128 },126 },
129 )127 )
gix/src/remote/connection/fetch/error.rs+5−0
@@ -40,6 +40,11 @@ pub enum Error { · 39 unmodified lines
40 feature: &'static str,40 feature: &'static str,
41 description: &'static str,41 description: &'static str,
42 },42 },
43 #[error("None of the refspec(s) {} matched any of the {num_remote_refs} refs on the remote", refspecs.iter().map(|r| r.to_ref().instruction().to_bstring().to_string()).collect::<Vec<_>>().join(", "))]
44 NoMapping {
45 refspecs: Vec<gix_refspec::RefSpec>,
46 num_remote_refs: usize,
47 },
43 #[error("Could not write 'shallow' file to incorporate remote updates after fetching")]48 #[error("Could not write 'shallow' file to incorporate remote updates after fetching")]
44 WriteShallowFile(#[from] crate::shallow::write::Error),49 WriteShallowFile(#[from] crate::shallow::write::Error),
45 #[error("'shallow' file could not be locked in preparation for writing changes")]50 #[error("'shallow' file could not be locked in preparation for writing changes")]
gix/src/remote/connection/fetch/receive_pack.rs+20−3
@@ -73,14 +73,32 @@ where · 72 unmodified lines
73 P: gix_features::progress::NestedProgress,73 P: gix_features::progress::NestedProgress,
74 P::SubProgress: 'static,74 P::SubProgress: 'static,
75 {75 {
76 let ref_map = &self.ref_map;
77 if ref_map.mappings.is_empty() && !ref_map.remote_refs.is_empty() {
78 let mut specs = ref_map.refspecs.clone();
79 specs.extend(ref_map.extra_refspecs.clone());
80 return Err(Error::NoMapping {
81 refspecs: specs,
82 num_remote_refs: ref_map.remote_refs.len(),
83 });
84 }
85
76 let mut con = self.con.take().expect("receive() can only be called once");86 let mut con = self.con.take().expect("receive() can only be called once");
77 let mut handshake = con.handshake.take().expect("receive() can only be called once");87 let mut handshake = con.handshake.take().expect("receive() can only be called once");
78 let repo = con.remote.repo;88 let repo = con.remote.repo;
89
90 let expected_object_hash = repo.object_hash();
91 if ref_map.object_hash != expected_object_hash {
92 return Err(Error::IncompatibleObjectHash {
93 local: expected_object_hash,
94 remote: ref_map.object_hash,
95 });
96 }
97
79 let fetch_options = gix_protocol::fetch::Options {98 let fetch_options = gix_protocol::fetch::Options {
80 shallow_file: repo.shallow_file(),99 shallow_file: repo.shallow_file(),
81 shallow: &self.shallow,100 shallow: &self.shallow,
82 tags: con.remote.fetch_tags,101 tags: con.remote.fetch_tags,
83 expected_object_hash: repo.object_hash(),
84 reject_shallow_remote: repo102 reject_shallow_remote: repo
85 .config103 .config
86 .resolved104 .resolved
@@ -95,7 +113,7 @@ where · 8 unmodified lines
95 user_agent: repo.config.user_agent_tuple(),113 user_agent: repo.config.user_agent_tuple(),
96 trace_packetlines: con.trace,114 trace_packetlines: con.trace,
97 };115 };
98 let ref_map = &self.ref_map;116
99 let negotiator = repo117 let negotiator = repo
100 .config118 .config
101 .resolved119 .resolved
@@ -137,7 +155,6 @@ where · 35 unmodified lines
137 let mut write_pack_bundle = None;155 let mut write_pack_bundle = None;
138 156
139 let res = gix_protocol::fetch(157 let res = gix_protocol::fetch(
140 ref_map,
141 &mut negotiate,158 &mut negotiate,
142 |reader, progress, should_interrupt| -> Result<bool, gix_pack::bundle::write::Error> {159 |reader, progress, should_interrupt| -> Result<bool, gix_pack::bundle::write::Error> {
143 let mut may_read_to_end = false;160 let mut may_read_to_end = false;