Skip to content

Commit 5950926

Browse files
committed
fix!: remove ref_map from fetch() function.
It's only uses for validation of the ref-maps own state, which is something that can be separate.
1 parent 972d720 commit 5950926

File tree

3 files changed

+2
-34
lines changed

3 files changed

+2
-34
lines changed

gix-protocol/src/fetch/error.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
pub enum Error {
55
#[error("Could not decode server reply")]
66
FetchResponse(#[from] crate::fetch::response::Error),
7-
#[error("Cannot fetch from a remote that uses {remote} while local repository uses {local} for object hashes")]
8-
IncompatibleObjectHash {
9-
local: gix_hash::Kind,
10-
remote: gix_hash::Kind,
11-
},
127
#[error(transparent)]
138
Negotiate(#[from] crate::fetch::negotiate::Error),
149
#[error(transparent)]
@@ -26,11 +21,6 @@ pub enum Error {
2621
LockShallowFile(#[from] gix_lock::acquire::Error),
2722
#[error("Receiving objects from shallow remotes is prohibited due to the value of `clone.rejectShallow`")]
2823
RejectShallowRemote,
29-
#[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(", "))]
30-
NoMapping {
31-
refspecs: Vec<gix_refspec::RefSpec>,
32-
num_remote_refs: usize,
33-
},
3424
#[error("Failed to consume the pack sent by the remove")]
3525
ConsumePack(Box<dyn std::error::Error + Send + Sync + 'static>),
3626
#[error("Failed to read remaining bytes in stream")]

gix-protocol/src/fetch/function.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use crate::fetch::{
2-
negotiate, Context, Error, Negotiate, NegotiateOutcome, Options, Outcome, ProgressId, RefMap, Shallow, Tags,
2+
negotiate, Context, Error, Negotiate, NegotiateOutcome, Options, Outcome, ProgressId, Shallow, Tags,
33
};
44
use crate::{fetch::Arguments, transport::packetline::read::ProgressAction};
55
use gix_features::progress::DynNestedProgress;
66
use std::path::Path;
77
use std::sync::atomic::{AtomicBool, Ordering};
88

9-
/// Perform one fetch operation, relying on a `transport`, right after a [`ref_map`](RefMap::new()) was created so
10-
/// it's clear what the remote has.
9+
/// Perform one fetch operation, relying on a `transport`.
1110
/// `negotiate` is used to run the negotiation of objects that should be contained in the pack, *if* one is to be received.
1211
/// `progress` and `should_interrupt` is passed to all potentially long-running parts of the operation.
1312
///
@@ -31,7 +30,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
3130
/// to inform about all the changes that were made.
3231
#[maybe_async::maybe_async]
3332
pub async fn fetch<P, T, E>(
34-
ref_map: &RefMap,
3533
negotiate: &mut impl Negotiate,
3634
consume_pack: impl FnOnce(&mut dyn std::io::BufRead, &mut dyn DynNestedProgress, &AtomicBool) -> Result<bool, E>,
3735
mut progress: P,
@@ -46,7 +44,6 @@ pub async fn fetch<P, T, E>(
4644
shallow_file,
4745
shallow,
4846
tags,
49-
expected_object_hash,
5047
reject_shallow_remote,
5148
}: Options<'_>,
5249
) -> Result<Option<Outcome>, Error>
@@ -57,16 +54,6 @@ where
5754
E: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
5855
{
5956
let _span = gix_trace::coarse!("gix_protocol::fetch()");
60-
61-
if ref_map.mappings.is_empty() && !ref_map.remote_refs.is_empty() {
62-
let mut specs = ref_map.refspecs.clone();
63-
specs.extend(ref_map.extra_refspecs.clone());
64-
return Err(Error::NoMapping {
65-
refspecs: specs,
66-
num_remote_refs: ref_map.remote_refs.len(),
67-
});
68-
}
69-
7057
let v1_shallow_updates = handshake.v1_shallow_updates.take();
7158
let protocol_version = handshake.server_protocol_version;
7259

@@ -93,13 +80,6 @@ where
9380
}
9481
let (shallow_commits, mut shallow_lock) = add_shallow_args(&mut arguments, shallow, &shallow_file)?;
9582

96-
if ref_map.object_hash != expected_object_hash {
97-
return Err(Error::IncompatibleObjectHash {
98-
local: expected_object_hash,
99-
remote: ref_map.object_hash,
100-
});
101-
}
102-
10383
let negotiate_span = gix_trace::detail!(
10484
"negotiate",
10585
protocol_version = handshake.server_protocol_version as usize

gix-protocol/src/fetch/types.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub struct Options<'a> {
1212
pub shallow: &'a Shallow,
1313
/// Describe how to handle tags when fetching.
1414
pub tags: Tags,
15-
/// The hash the remote repository is expected to use, as it's what the local repository is initialized as.
16-
pub expected_object_hash: gix_hash::Kind,
1715
/// If `true`, if we fetch from a remote that only offers shallow clones, the operation will fail with an error
1816
/// instead of writing the shallow boundary to the shallow file.
1917
pub reject_shallow_remote: bool,

0 commit comments

Comments
 (0)