summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/remote
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/gix/src/remote
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/remote')
-rw-r--r--vendor/gix/src/remote/connect.rs6
-rw-r--r--vendor/gix/src/remote/connection/fetch/mod.rs3
-rw-r--r--vendor/gix/src/remote/connection/fetch/negotiate.rs2
-rw-r--r--vendor/gix/src/remote/connection/fetch/receive_pack.rs59
-rw-r--r--vendor/gix/src/remote/connection/fetch/update_refs/mod.rs14
-rw-r--r--vendor/gix/src/remote/connection/fetch/update_refs/tests.rs2
-rw-r--r--vendor/gix/src/remote/connection/mod.rs1
-rw-r--r--vendor/gix/src/remote/connection/ref_map.rs5
8 files changed, 55 insertions, 37 deletions
diff --git a/vendor/gix/src/remote/connect.rs b/vendor/gix/src/remote/connect.rs
index 6acc9f67f..df2b36230 100644
--- a/vendor/gix/src/remote/connect.rs
+++ b/vendor/gix/src/remote/connect.rs
@@ -1,8 +1,9 @@
#![allow(clippy::result_large_err)]
-use gix_protocol::transport::client::Transport;
use std::borrow::Cow;
+use gix_protocol::transport::client::Transport;
+
use crate::{remote::Connection, Remote};
mod error {
@@ -57,11 +58,13 @@ impl<'repo> Remote<'repo> {
where
T: Transport,
{
+ let trace = self.repo.config.trace_packet();
Connection {
remote: self,
authenticate: None,
transport_options: None,
transport,
+ trace,
}
}
@@ -91,6 +94,7 @@ impl<'repo> Remote<'repo> {
.then(|| self.repo.ssh_connect_options())
.transpose()?
.unwrap_or_default(),
+ trace: self.repo.config.trace_packet(),
},
)
.await?;
diff --git a/vendor/gix/src/remote/connection/fetch/mod.rs b/vendor/gix/src/remote/connection/fetch/mod.rs
index 8327d5abc..d4afd1023 100644
--- a/vendor/gix/src/remote/connection/fetch/mod.rs
+++ b/vendor/gix/src/remote/connection/fetch/mod.rs
@@ -281,12 +281,13 @@ where
// connection in an async context.
gix_protocol::futures_lite::future::block_on(gix_protocol::indicate_end_of_interaction(
&mut con.transport,
+ con.trace,
))
.ok();
}
#[cfg(not(feature = "async-network-client"))]
{
- gix_protocol::indicate_end_of_interaction(&mut con.transport).ok();
+ gix_protocol::indicate_end_of_interaction(&mut con.transport, con.trace).ok();
}
}
}
diff --git a/vendor/gix/src/remote/connection/fetch/negotiate.rs b/vendor/gix/src/remote/connection/fetch/negotiate.rs
index 92a141f6f..f5b6a031c 100644
--- a/vendor/gix/src/remote/connection/fetch/negotiate.rs
+++ b/vendor/gix/src/remote/connection/fetch/negotiate.rs
@@ -16,7 +16,7 @@ pub enum Error {
#[error("We were unable to figure out what objects the server should send after {rounds} round(s)")]
NegotiationFailed { rounds: usize },
#[error(transparent)]
- LookupCommitInGraph(#[from] gix_revwalk::graph::lookup::commit::Error),
+ LookupCommitInGraph(#[from] gix_revwalk::graph::try_lookup_or_insert_default::Error),
#[error(transparent)]
InitRefsIterator(#[from] crate::reference::iter::init::Error),
#[error(transparent)]
diff --git a/vendor/gix/src/remote/connection/fetch/receive_pack.rs b/vendor/gix/src/remote/connection/fetch/receive_pack.rs
index 18e5ac159..7634b34cf 100644
--- a/vendor/gix/src/remote/connection/fetch/receive_pack.rs
+++ b/vendor/gix/src/remote/connection/fetch/receive_pack.rs
@@ -3,7 +3,7 @@ use std::{
sync::atomic::{AtomicBool, Ordering},
};
-use gix_odb::{store::RefreshMode, FindExt};
+use gix_odb::store::RefreshMode;
use gix_protocol::{
fetch::Arguments,
transport::{client::Transport, packetline::read::ProgressAction},
@@ -104,7 +104,7 @@ where
gix_protocol::fetch::Response::check_required_features(protocol_version, &fetch_features)?;
let sideband_all = fetch_features.iter().any(|(n, _)| *n == "sideband-all");
- let mut arguments = gix_protocol::fetch::Arguments::new(protocol_version, fetch_features);
+ let mut arguments = gix_protocol::fetch::Arguments::new(protocol_version, fetch_features, con.trace);
if matches!(con.remote.fetch_tags, crate::remote::fetch::Tags::Included) {
if !arguments.can_use_include_tag() {
return Err(Error::MissingServerFeature {
@@ -125,7 +125,10 @@ where
});
}
- let negotiate_span = gix_trace::detail!("negotiate");
+ let negotiate_span = gix_trace::detail!(
+ "negotiate",
+ protocol_version = self.ref_map.handshake.server_protocol_version as usize
+ );
let mut negotiator = repo
.config
.resolved
@@ -155,7 +158,9 @@ where
let mut previous_response = None::<gix_protocol::fetch::Response>;
let (mut write_pack_bundle, negotiate) = match &action {
negotiate::Action::NoChange | negotiate::Action::SkipToRefUpdate => {
- gix_protocol::indicate_end_of_interaction(&mut con.transport).await.ok();
+ gix_protocol::indicate_end_of_interaction(&mut con.transport, con.trace)
+ .await
+ .ok();
(None, None)
}
negotiate::Action::MustNegotiate {
@@ -206,7 +211,9 @@ where
is_done
}
Err(err) => {
- gix_protocol::indicate_end_of_interaction(&mut con.transport).await.ok();
+ gix_protocol::indicate_end_of_interaction(&mut con.transport, con.trace)
+ .await
+ .ok();
return Err(err.into());
}
};
@@ -214,8 +221,13 @@ where
if sideband_all {
setup_remote_progress(progress, &mut reader, should_interrupt);
}
- let response =
- gix_protocol::fetch::Response::from_line_reader(protocol_version, &mut reader, is_done).await?;
+ let response = gix_protocol::fetch::Response::from_line_reader(
+ protocol_version,
+ &mut reader,
+ is_done,
+ !is_done,
+ )
+ .await?;
let has_pack = response.has_pack();
previous_response = Some(response);
if has_pack {
@@ -265,14 +277,23 @@ where
should_interrupt,
Some(Box::new({
let repo = repo.clone();
- move |oid, buf| repo.objects.find(&oid, buf).ok()
+ repo.objects
})),
options,
)?;
+ // Assure the final flush packet is consumed.
+ #[cfg(feature = "async-network-client")]
+ let has_read_to_end = { rd.get_ref().stopped_at().is_some() };
+ #[cfg(not(feature = "async-network-client"))]
+ let has_read_to_end = { rd.stopped_at().is_some() };
+ if !has_read_to_end {
+ std::io::copy(&mut rd, &mut std::io::sink()).unwrap();
+ }
#[cfg(feature = "async-network-client")]
{
reader = rd.into_inner();
}
+
#[cfg(not(feature = "async-network-client"))]
{
reader = rd;
@@ -284,7 +305,9 @@ where
drop(reader);
if matches!(protocol_version, gix_protocol::transport::Protocol::V2) {
- gix_protocol::indicate_end_of_interaction(&mut con.transport).await.ok();
+ gix_protocol::indicate_end_of_interaction(&mut con.transport, con.trace)
+ .await
+ .ok();
}
if let Some(shallow_lock) = shallow_lock {
@@ -387,24 +410,14 @@ fn add_shallow_args(
Ok((shallow_commits, shallow_lock))
}
-fn setup_remote_progress(
+fn setup_remote_progress<'a>(
progress: &mut dyn crate::DynNestedProgress,
- reader: &mut Box<dyn gix_protocol::transport::client::ExtendedBufRead + Unpin + '_>,
- should_interrupt: &AtomicBool,
+ reader: &mut Box<dyn gix_protocol::transport::client::ExtendedBufRead<'a> + Unpin + 'a>,
+ should_interrupt: &'a AtomicBool,
) {
use gix_protocol::transport::client::ExtendedBufRead;
reader.set_progress_handler(Some(Box::new({
let mut remote_progress = progress.add_child_with_id("remote".to_string(), ProgressId::RemoteProgress.into());
- // SAFETY: Ugh, so, with current Rust I can't declare lifetimes in the involved traits the way they need to
- // be and I also can't use scoped threads to pump from local scopes to an Arc version that could be
- // used here due to the this being called from sync AND async code (and the async version doesn't work
- // with a surrounding `std::thread::scope()`.
- // Thus there is only claiming this is 'static which we know works for *our* implementations of ExtendedBufRead
- // and typical implementations, but of course it's possible for user code to come along and actually move this
- // handler into a context where it can outlive the current function. Is this going to happen? Probably not unless
- // somebody really wants to break it. So, with standard usage this value is never used past its actual lifetime.
- #[allow(unsafe_code)]
- let should_interrupt: &'static AtomicBool = unsafe { std::mem::transmute(should_interrupt) };
move |is_err: bool, data: &[u8]| {
gix_protocol::RemoteProgress::translate_to_progress(is_err, data, &mut remote_progress);
if should_interrupt.load(Ordering::Relaxed) {
@@ -413,5 +426,5 @@ fn setup_remote_progress(
ProgressAction::Continue
}
}
- }) as gix_protocol::transport::client::HandleProgress));
+ }) as gix_protocol::transport::client::HandleProgress<'a>));
}
diff --git a/vendor/gix/src/remote/connection/fetch/update_refs/mod.rs b/vendor/gix/src/remote/connection/fetch/update_refs/mod.rs
index 3d6fb18bd..c487e7f5c 100644
--- a/vendor/gix/src/remote/connection/fetch/update_refs/mod.rs
+++ b/vendor/gix/src/remote/connection/fetch/update_refs/mod.rs
@@ -1,7 +1,7 @@
#![allow(clippy::result_large_err)]
use std::{collections::BTreeMap, convert::TryInto, path::PathBuf};
-use gix_odb::{Find, FindExt};
+use gix_object::Exists;
use gix_ref::{
transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog},
Target, TargetRef,
@@ -96,8 +96,8 @@ pub(crate) fn update(
) {
// `None` only if unborn.
let remote_id = remote.as_id();
- if matches!(dry_run, fetch::DryRun::No) && !remote_id.map_or(true, |id| repo.objects.contains(id)) {
- if let Some(remote_id) = remote_id.filter(|id| !repo.objects.contains(id)) {
+ if matches!(dry_run, fetch::DryRun::No) && !remote_id.map_or(true, |id| repo.objects.exists(id)) {
+ if let Some(remote_id) = remote_id.filter(|id| !repo.objects.exists(id)) {
let update = if is_implicit_tag {
Mode::ImplicitTagNotSentByRemote.into()
} else {
@@ -159,7 +159,7 @@ pub(crate) fn update(
}).and_then(|local_commit_time|
remote_id
.to_owned()
- .ancestors(|id, buf| repo.objects.find_commit_iter(id, buf))
+ .ancestors(&repo.objects)
.sorting(
gix_traverse::commit::Sorting::ByCommitTimeNewestFirstCutoffOlderThan {
seconds: local_commit_time
@@ -325,11 +325,7 @@ pub(crate) fn update(
.packed_refs(
match write_packed_refs {
fetch::WritePackedRefs::Only => {
- gix_ref::file::transaction::PackedRefs::DeletionsAndNonSymbolicUpdatesRemoveLooseSourceReference(Box::new(|oid, buf| {
- repo.objects
- .try_find(&oid, buf)
- .map(|obj| obj.map(|obj| obj.kind))
- }))},
+ gix_ref::file::transaction::PackedRefs::DeletionsAndNonSymbolicUpdatesRemoveLooseSourceReference(Box::new(&repo.objects))},
fetch::WritePackedRefs::Never => gix_ref::file::transaction::PackedRefs::DeletionsOnly
}
)
diff --git a/vendor/gix/src/remote/connection/fetch/update_refs/tests.rs b/vendor/gix/src/remote/connection/fetch/update_refs/tests.rs
index 0b29f14f4..27501720d 100644
--- a/vendor/gix/src/remote/connection/fetch/update_refs/tests.rs
+++ b/vendor/gix/src/remote/connection/fetch/update_refs/tests.rs
@@ -191,7 +191,7 @@ mod update {
#[test]
fn checked_out_branches_in_worktrees_are_rejected_with_additional_information() -> Result {
- let root = gix_path::realpath(&gix_testtools::scripted_fixture_read_only_with_args(
+ let root = gix_path::realpath(gix_testtools::scripted_fixture_read_only_with_args(
"make_fetch_repos.sh",
[base_repo_path()],
)?)?;
diff --git a/vendor/gix/src/remote/connection/mod.rs b/vendor/gix/src/remote/connection/mod.rs
index 02a09926a..f9b8aa7e6 100644
--- a/vendor/gix/src/remote/connection/mod.rs
+++ b/vendor/gix/src/remote/connection/mod.rs
@@ -17,6 +17,7 @@ pub struct Connection<'a, 'repo, T> {
pub(crate) authenticate: Option<AuthenticateFn<'a>>,
pub(crate) transport_options: Option<Box<dyn std::any::Any>>,
pub(crate) transport: T,
+ pub(crate) trace: bool,
}
mod access;
diff --git a/vendor/gix/src/remote/connection/ref_map.rs b/vendor/gix/src/remote/connection/ref_map.rs
index f1b40d56e..bf53cf35f 100644
--- a/vendor/gix/src/remote/connection/ref_map.rs
+++ b/vendor/gix/src/remote/connection/ref_map.rs
@@ -95,7 +95,7 @@ where
#[gix_protocol::maybe_async::maybe_async]
pub async fn ref_map(mut self, progress: impl Progress, options: Options) -> Result<fetch::RefMap, Error> {
let res = self.ref_map_inner(progress, options).await;
- gix_protocol::indicate_end_of_interaction(&mut self.transport)
+ gix_protocol::indicate_end_of_interaction(&mut self.transport, self.trace)
.await
.ok();
res
@@ -112,6 +112,7 @@ where
mut extra_refspecs,
}: Options,
) -> Result<fetch::RefMap, Error> {
+ let _span = gix_trace::coarse!("remote::Connection::ref_map()");
let null = gix_hash::ObjectId::null(gix_hash::Kind::Sha1); // OK to hardcode Sha1, it's not supposed to match, ever.
if let Some(tag_spec) = self.remote.fetch_tags.to_refspec().map(|spec| spec.to_owned()) {
@@ -186,6 +187,7 @@ where
refspecs: &[gix_refspec::RefSpec],
mut progress: impl Progress,
) -> Result<HandshakeWithRefs, Error> {
+ let _span = gix_trace::coarse!("remote::Connection::fetch_refs()");
let mut credentials_storage;
let url = self.transport.to_url();
let authenticate = match self.authenticate.as_mut() {
@@ -241,6 +243,7 @@ where
Ok(gix_protocol::ls_refs::Action::Continue)
},
&mut progress,
+ self.trace,
)
.await?
}