Skip to content

Commit a542775

Browse files
authored
Merge pull request #1726 from GitoxideLabs/radicle-tuning
radicle tuning
2 parents 972d720 + d1d3f7c commit a542775

File tree

7 files changed

+29
-41
lines changed

7 files changed

+29
-41
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-protocol/src/fetch/error.rs

-10
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

+2-22
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

-2
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,

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;

tests/journey/gix.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ title "gix (with repository)"
109109

110110
# for some reason, on CI the daemon always shuts down before we can connect,
111111
# or isn't actually ready despite having accepted the first connection already.
112-
(with "git:// protocol"
112+
(not_on_ci with "git:// protocol"
113113
launch-git-daemon
114114
(with "version 1"
115115
it "generates the correct output" && {
@@ -278,7 +278,7 @@ title "gix commit-graph"
278278
)
279279
)
280280
fi
281-
(with "git:// protocol"
281+
(not_on_ci with "git:// protocol"
282282
launch-git-daemon
283283
(with "version 1"
284284
(with "NO output directory"

0 commit comments

Comments
 (0)