Skip to content

Commit 25b8480

Browse files
committed
adapt to changes in gix-protocol
1 parent 5950926 commit 25b8480

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

gitoxide-core/src/pack/receive.rs

-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ where
9494
.await?;
9595
let mut negotiate = Negotiate { refmap: &refmap };
9696
gix::protocol::fetch(
97-
&refmap,
9897
&mut negotiate,
9998
|read_pack, progress, should_interrupt| {
10099
receive_pack_blocking(
@@ -123,7 +122,6 @@ where
123122
shallow_file: "no shallow file required as we reject it to keep it simple".into(),
124123
shallow: &Default::default(),
125124
tags: Default::default(),
126-
expected_object_hash: Default::default(),
127125
reject_shallow_remote: true,
128126
},
129127
)

gix/src/remote/connection/fetch/error.rs

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ pub enum Error {
4040
feature: &'static str,
4141
description: &'static str,
4242
},
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+
},
4348
#[error("Could not write 'shallow' file to incorporate remote updates after fetching")]
4449
WriteShallowFile(#[from] crate::shallow::write::Error),
4550
#[error("'shallow' file could not be locked in preparation for writing changes")]

gix/src/remote/connection/fetch/receive_pack.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,32 @@ where
7373
P: gix_features::progress::NestedProgress,
7474
P::SubProgress: 'static,
7575
{
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+
7686
let mut con = self.con.take().expect("receive() can only be called once");
7787
let mut handshake = con.handshake.take().expect("receive() can only be called once");
7888
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+
7998
let fetch_options = gix_protocol::fetch::Options {
8099
shallow_file: repo.shallow_file(),
81100
shallow: &self.shallow,
82101
tags: con.remote.fetch_tags,
83-
expected_object_hash: repo.object_hash(),
84102
reject_shallow_remote: repo
85103
.config
86104
.resolved
@@ -95,7 +113,7 @@ where
95113
user_agent: repo.config.user_agent_tuple(),
96114
trace_packetlines: con.trace,
97115
};
98-
let ref_map = &self.ref_map;
116+
99117
let negotiator = repo
100118
.config
101119
.resolved
@@ -137,7 +155,6 @@ where
137155
let mut write_pack_bundle = None;
138156

139157
let res = gix_protocol::fetch(
140-
ref_map,
141158
&mut negotiate,
142159
|reader, progress, should_interrupt| -> Result<bool, gix_pack::bundle::write::Error> {
143160
let mut may_read_to_end = false;

0 commit comments

Comments
 (0)