From 645d4c6861a490d76877a6b5a268db963c5569d6 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 8 Sep 2023 21:03:10 +0200 Subject: [PATCH 1/2] update `gix` to the latest version Please note that I have removed the `max-performance-safe` feature which pushes the choice to the consumer of (any) library that uses `gix`. It's also causing less C to be compiled by default. --- Cargo.toml | 5 +---- src/index/git_remote.rs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 332777d..b836c34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,13 +59,10 @@ twox-hash = { version = "1.6", default-features = false } [dependencies.gix] optional = true -version = "0.52" +version = "0.53.1" default-features = false features = [ - "max-performance-safe", - "blocking-network-client", "blocking-http-transport-reqwest", - "reqwest-for-configuration-only", ] [dependencies.reqwest] diff --git a/src/index/git_remote.rs b/src/index/git_remote.rs index d838ff3..cef10e1 100644 --- a/src/index/git_remote.rs +++ b/src/index/git_remote.rs @@ -63,7 +63,7 @@ impl RemoteGitIndex { lock_policy: gix::lock::acquire::Fail, ) -> Result where - P: gix::Progress, + P: gix::NestedProgress, P::SubProgress: 'static, { let open_or_clone_repo = || -> Result<_, GitError> { @@ -339,7 +339,7 @@ impl RemoteGitIndex { should_interrupt: &AtomicBool, ) -> Result<(), Error> where - P: gix::Progress, + P: gix::NestedProgress, P::SubProgress: 'static, { // We're updating the reflog which requires a committer be set, which might @@ -416,7 +416,7 @@ pub enum GitError { #[error(transparent)] ReferenceLookup(#[from] Box), #[error(transparent)] - BlobLookup(#[from] Box>), + BlobLookup(#[from] Box), #[error(transparent)] RemoteLookup(#[from] Box), #[error(transparent)] From 0eb7fc558b1eae54d5dc8d30384bbf5973cc232d Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 11 Sep 2023 11:10:47 +0200 Subject: [PATCH 2/2] Box 2 largest variants --- src/index/git_remote.rs | 102 +++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/src/index/git_remote.rs b/src/index/git_remote.rs index cef10e1..2326172 100644 --- a/src/index/git_remote.rs +++ b/src/index/git_remote.rs @@ -118,7 +118,8 @@ impl RemoteGitIndex { .configure_remote(|remote| { Ok(remote.with_refspecs(["+HEAD:refs/remotes/origin/HEAD"], DIR)?) }) - .fetch_only(progress, should_interrupt)?; + .fetch_only(progress, should_interrupt) + .map_err(|err| GitError::from(Box::new(err)))?; (repo, Some(out)) }; @@ -378,7 +379,7 @@ impl RemoteGitIndex { .prepare_fetch(&mut progress, Default::default()) .map_err(|err| GitError::from(Box::new(err)))? .receive(&mut progress, should_interrupt) - .map_err(GitError::from)?; + .map_err(|err| GitError::from(Box::new(err)))?; crate::utils::git::write_fetch_head(&repo, &outcome, &remote)?; self.head_commit = Self::set_head(&mut self.index, &repo)?; @@ -394,13 +395,13 @@ pub enum GitError { #[error(transparent)] ClonePrep(#[from] Box), #[error(transparent)] - CloneFetch(#[from] gix::clone::fetch::Error), + CloneFetch(#[from] Box), #[error(transparent)] Connect(#[from] Box), #[error(transparent)] FetchPrep(#[from] Box), #[error(transparent)] - Fetch(#[from] gix::remote::fetch::Error), + Fetch(#[from] Box), #[error(transparent)] Open(#[from] Box), #[error(transparent)] @@ -440,54 +441,71 @@ impl GitError { pub fn is_spurious(&self) -> bool { use gix::protocol::transport::IsSpuriousError; - if let Self::Fetch(fe) | Self::CloneFetch(gix::clone::fetch::Error::Fetch(fe)) = self { - fe.is_spurious() - } else { - false + match self { + Self::Fetch(fe) => return fe.is_spurious(), + Self::CloneFetch(cf) => { + if let gix::clone::fetch::Error::Fetch(fe) = &**cf { + return fe.is_spurious(); + } + } + _ => {} } + + false } /// Returns true if a fetch could not be completed successfully due to the /// repo being locked, and could succeed if retried #[inline] pub fn is_locked(&self) -> bool { - match self { - Self::Fetch(gix::remote::fetch::Error::UpdateRefs(ure)) - | Self::CloneFetch(gix::clone::fetch::Error::Fetch( - gix::remote::fetch::Error::UpdateRefs(ure), - )) => { - if let gix::remote::fetch::refs::update::Error::EditReferences(ere) = ure { - match ere { - gix::reference::edit::Error::FileTransactionPrepare(ftpe) => { - use gix::refs::file::transaction::prepare::Error as PrepError; - if let PrepError::LockAcquire { source, .. } - | PrepError::PackedTransactionAcquire(source) = ftpe - { - // currently this is either io or permanentlylocked, but just in case - // more variants are added, we just assume it's possible to retry - // in anything but the permanentlylocked variant - !matches!( - source, - gix::lock::acquire::Error::PermanentlyLocked { .. } - ) - } else { - false - } - } - gix::reference::edit::Error::FileTransactionCommit(ftce) => { - matches!( - ftce, - gix::refs::file::transaction::commit::Error::LockCommit { .. } - ) - } - _ => false, - } + let ure = match self { + Self::Fetch(fe) => { + if let gix::remote::fetch::Error::UpdateRefs(ure) = &**fe { + ure + } else { + return false; + } + } + Self::CloneFetch(cf) => { + if let gix::clone::fetch::Error::Fetch(gix::remote::fetch::Error::UpdateRefs(ure)) = + &**cf + { + ure } else { - false + return false; } } - Self::Lock(le) => !matches!(le, gix::lock::acquire::Error::PermanentlyLocked { .. }), - _ => false, + Self::Lock(le) => { + return !matches!(le, gix::lock::acquire::Error::PermanentlyLocked { .. }) + } + _ => return false, + }; + + if let gix::remote::fetch::refs::update::Error::EditReferences(ere) = ure { + match ere { + gix::reference::edit::Error::FileTransactionPrepare(ftpe) => { + use gix::refs::file::transaction::prepare::Error as PrepError; + if let PrepError::LockAcquire { source, .. } + | PrepError::PackedTransactionAcquire(source) = ftpe + { + // currently this is either io or permanentlylocked, but just in case + // more variants are added, we just assume it's possible to retry + // in anything but the permanentlylocked variant + !matches!(source, gix::lock::acquire::Error::PermanentlyLocked { .. }) + } else { + false + } + } + gix::reference::edit::Error::FileTransactionCommit(ftce) => { + matches!( + ftce, + gix::refs::file::transaction::commit::Error::LockCommit { .. } + ) + } + _ => false, + } + } else { + false } } }