Skip to content

Commit

Permalink
adapt to changes in gix-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Dec 17, 2024
1 parent 5950926 commit 25b8480
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 0 additions & 2 deletions gitoxide-core/src/pack/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ where
.await?;
let mut negotiate = Negotiate { refmap: &refmap };
gix::protocol::fetch(
&refmap,
&mut negotiate,
|read_pack, progress, should_interrupt| {
receive_pack_blocking(
Expand Down Expand Up @@ -123,7 +122,6 @@ where
shallow_file: "no shallow file required as we reject it to keep it simple".into(),
shallow: &Default::default(),
tags: Default::default(),
expected_object_hash: Default::default(),
reject_shallow_remote: true,
},
)
Expand Down
5 changes: 5 additions & 0 deletions gix/src/remote/connection/fetch/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ pub enum Error {
feature: &'static str,
description: &'static str,
},
#[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(", "))]
NoMapping {
refspecs: Vec<gix_refspec::RefSpec>,
num_remote_refs: usize,
},
#[error("Could not write 'shallow' file to incorporate remote updates after fetching")]
WriteShallowFile(#[from] crate::shallow::write::Error),
#[error("'shallow' file could not be locked in preparation for writing changes")]
Expand Down
23 changes: 20 additions & 3 deletions gix/src/remote/connection/fetch/receive_pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,32 @@ where
P: gix_features::progress::NestedProgress,
P::SubProgress: 'static,
{
let ref_map = &self.ref_map;
if ref_map.mappings.is_empty() && !ref_map.remote_refs.is_empty() {
let mut specs = ref_map.refspecs.clone();
specs.extend(ref_map.extra_refspecs.clone());
return Err(Error::NoMapping {
refspecs: specs,
num_remote_refs: ref_map.remote_refs.len(),
});
}

let mut con = self.con.take().expect("receive() can only be called once");
let mut handshake = con.handshake.take().expect("receive() can only be called once");
let repo = con.remote.repo;

let expected_object_hash = repo.object_hash();
if ref_map.object_hash != expected_object_hash {
return Err(Error::IncompatibleObjectHash {
local: expected_object_hash,
remote: ref_map.object_hash,
});
}

let fetch_options = gix_protocol::fetch::Options {
shallow_file: repo.shallow_file(),
shallow: &self.shallow,
tags: con.remote.fetch_tags,
expected_object_hash: repo.object_hash(),
reject_shallow_remote: repo
.config
.resolved
Expand All @@ -95,7 +113,7 @@ where
user_agent: repo.config.user_agent_tuple(),
trace_packetlines: con.trace,
};
let ref_map = &self.ref_map;

let negotiator = repo
.config
.resolved
Expand Down Expand Up @@ -137,7 +155,6 @@ where
let mut write_pack_bundle = None;

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

0 comments on commit 25b8480

Please sign in to comment.