summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/clone
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix/src/clone')
-rw-r--r--vendor/gix/src/clone/checkout.rs39
-rw-r--r--vendor/gix/src/clone/fetch/mod.rs21
-rw-r--r--vendor/gix/src/clone/fetch/util.rs12
-rw-r--r--vendor/gix/src/clone/mod.rs31
4 files changed, 70 insertions, 33 deletions
diff --git a/vendor/gix/src/clone/checkout.rs b/vendor/gix/src/clone/checkout.rs
index 823005551..ece480a56 100644
--- a/vendor/gix/src/clone/checkout.rs
+++ b/vendor/gix/src/clone/checkout.rs
@@ -26,9 +26,7 @@ pub mod main_worktree {
#[error(transparent)]
CheckoutOptions(#[from] crate::config::checkout_options::Error),
#[error(transparent)]
- IndexCheckout(
- #[from] gix_worktree::checkout::Error<gix_odb::find::existing_object::Error<gix_odb::store::find::Error>>,
- ),
+ IndexCheckout(#[from] gix_worktree_state::checkout::Error<gix_odb::find::existing_object::Error>),
#[error("Failed to reopen object database as Arc (only if thread-safety wasn't compiled in)")]
OpenArcOdb(#[from] std::io::Error),
#[error("The HEAD reference could not be located")]
@@ -64,11 +62,24 @@ pub mod main_worktree {
///
/// Note that this is a no-op if the remote was empty, leaving this repository empty as well. This can be validated by checking
/// if the `head()` of the returned repository is not unborn.
- pub fn main_worktree(
+ pub fn main_worktree<P>(
&mut self,
- mut progress: impl crate::Progress,
+ mut progress: P,
should_interrupt: &AtomicBool,
- ) -> Result<(Repository, gix_worktree::checkout::Outcome), Error> {
+ ) -> Result<(Repository, gix_worktree_state::checkout::Outcome), Error>
+ where
+ P: gix_features::progress::NestedProgress,
+ P::SubProgress: gix_features::progress::NestedProgress + 'static,
+ {
+ self.main_worktree_inner(&mut progress, should_interrupt)
+ }
+
+ fn main_worktree_inner(
+ &mut self,
+ progress: &mut dyn gix_features::progress::DynNestedProgress,
+ should_interrupt: &AtomicBool,
+ ) -> Result<(Repository, gix_worktree_state::checkout::Outcome), Error> {
+ let _span = gix_trace::coarse!("gix::clone::PrepareCheckout::main_worktree()");
let repo = self
.repo
.as_ref()
@@ -81,7 +92,7 @@ pub mod main_worktree {
None => {
return Ok((
self.repo.take().expect("still present"),
- gix_worktree::checkout::Outcome::default(),
+ gix_worktree_state::checkout::Outcome::default(),
))
}
};
@@ -92,25 +103,27 @@ pub mod main_worktree {
})?;
let mut index = gix_index::File::from_state(index, repo.index_path());
- let mut opts = repo.config.checkout_options(repo.git_dir())?;
+ let mut opts = repo
+ .config
+ .checkout_options(repo, gix_worktree::stack::state::attributes::Source::IdMapping)?;
opts.destination_is_initially_empty = true;
- let mut files = progress.add_child_with_id("checkout", ProgressId::CheckoutFiles.into());
- let mut bytes = progress.add_child_with_id("writing", ProgressId::BytesWritten.into());
+ let mut files = progress.add_child_with_id("checkout".to_string(), ProgressId::CheckoutFiles.into());
+ let mut bytes = progress.add_child_with_id("writing".to_string(), ProgressId::BytesWritten.into());
files.init(Some(index.entries().len()), crate::progress::count("files"));
bytes.init(None, crate::progress::bytes());
let start = std::time::Instant::now();
- let outcome = gix_worktree::checkout(
+ let outcome = gix_worktree_state::checkout(
&mut index,
workdir,
{
let objects = repo.objects.clone().into_arc()?;
move |oid, buf| objects.find_blob(oid, buf)
},
- &mut files,
- &mut bytes,
+ &files,
+ &bytes,
should_interrupt,
opts,
)?;
diff --git a/vendor/gix/src/clone/fetch/mod.rs b/vendor/gix/src/clone/fetch/mod.rs
index e20cc96cb..c03b8f839 100644
--- a/vendor/gix/src/clone/fetch/mod.rs
+++ b/vendor/gix/src/clone/fetch/mod.rs
@@ -26,7 +26,7 @@ pub enum Error {
SaveConfigIo(#[from] std::io::Error),
#[error("The remote HEAD points to a reference named {head_ref_name:?} which is invalid.")]
InvalidHeadRef {
- source: gix_validate::refname::Error,
+ source: gix_validate::reference::name::Error,
head_ref_name: crate::bstr::BString,
},
#[error("Failed to update HEAD with values from remote")]
@@ -55,9 +55,18 @@ impl PrepareFetch {
should_interrupt: &std::sync::atomic::AtomicBool,
) -> Result<(crate::Repository, crate::remote::fetch::Outcome), Error>
where
- P: crate::Progress,
+ P: crate::NestedProgress,
P::SubProgress: 'static,
{
+ self.fetch_only_inner(&mut progress, should_interrupt).await
+ }
+
+ #[gix_protocol::maybe_async::maybe_async]
+ async fn fetch_only_inner(
+ &mut self,
+ progress: &mut dyn crate::DynNestedProgress,
+ should_interrupt: &std::sync::atomic::AtomicBool,
+ ) -> Result<(crate::Repository, crate::remote::fetch::Outcome), Error> {
use crate::{bstr::ByteVec, remote, remote::fetch::RefLogMessage};
let repo = self
@@ -111,7 +120,7 @@ impl PrepareFetch {
f(&mut connection).map_err(|err| Error::RemoteConnection(err))?;
}
connection
- .prepare_fetch(&mut progress, {
+ .prepare_fetch(&mut *progress, {
let mut opts = self.fetch_options.clone();
if !opts.extra_refspecs.contains(&head_refspec) {
opts.extra_refspecs.push(head_refspec)
@@ -134,7 +143,7 @@ impl PrepareFetch {
message: reflog_message.clone(),
})
.with_shallow(self.shallow.clone())
- .receive(progress, should_interrupt)
+ .receive_inner(progress, should_interrupt)
.await?;
util::append_config_to_repo_config(repo, config);
@@ -149,14 +158,14 @@ impl PrepareFetch {
}
/// Similar to [`fetch_only()`][Self::fetch_only()`], but passes ownership to a utility type to configure a checkout operation.
- #[cfg(feature = "blocking-network-client")]
+ #[cfg(all(feature = "worktree-mutation", feature = "blocking-network-client"))]
pub fn fetch_then_checkout<P>(
&mut self,
progress: P,
should_interrupt: &std::sync::atomic::AtomicBool,
) -> Result<(crate::clone::PrepareCheckout, crate::remote::fetch::Outcome), Error>
where
- P: crate::Progress,
+ P: crate::NestedProgress,
P::SubProgress: 'static,
{
let (repo, fetch_outcome) = self.fetch_only(progress, should_interrupt)?;
diff --git a/vendor/gix/src/clone/fetch/util.rs b/vendor/gix/src/clone/fetch/util.rs
index cb79669ac..ab90435d0 100644
--- a/vendor/gix/src/clone/fetch/util.rs
+++ b/vendor/gix/src/clone/fetch/util.rs
@@ -51,7 +51,7 @@ fn write_to_local_config(config: &gix_config::File<'static>, mode: WriteMode) ->
.append(matches!(mode, WriteMode::Append))
.open(config.meta().path.as_deref().expect("local config with path set"))?;
local_config.write_all(config.detect_newline_style())?;
- config.write_to_filter(&mut local_config, |s| s.meta().source == gix_config::Source::Local)
+ config.write_to_filter(&mut local_config, &mut |s| s.meta().source == gix_config::Source::Local)
}
pub fn append_config_to_repo_config(repo: &mut Repository, config: gix_config::File<'static>) {
@@ -76,6 +76,7 @@ pub fn update_head(
gix_protocol::handshake::Ref::Symbolic {
full_ref_name,
target,
+ tag: _,
object,
} if full_ref_name == "HEAD" => (Some(object.as_ref()), Some(target)),
gix_protocol::handshake::Ref::Direct { full_ref_name, object } if full_ref_name == "HEAD" => {
@@ -106,12 +107,7 @@ pub fn update_head(
repo.refs
.transaction()
.packed_refs(gix_ref::file::transaction::PackedRefs::DeletionsAndNonSymbolicUpdates(
- Box::new(|oid, buf| {
- repo.objects
- .try_find(oid, buf)
- .map(|obj| obj.map(|obj| obj.kind))
- .map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync + 'static>)
- }),
+ Box::new(|oid, buf| repo.objects.try_find(&oid, buf).map(|obj| obj.map(|obj| obj.kind))),
))
.prepare(
{
@@ -202,7 +198,7 @@ fn setup_branch_config(
let remote = repo
.find_remote(remote_name)
.expect("remote was just created and must be visible in config");
- let group = gix_refspec::MatchGroup::from_fetch_specs(remote.fetch_specs.iter().map(|s| s.to_ref()));
+ let group = gix_refspec::MatchGroup::from_fetch_specs(remote.fetch_specs.iter().map(gix_refspec::RefSpec::to_ref));
let null = gix_hash::ObjectId::null(repo.object_hash());
let res = group.match_remotes(
Some(gix_refspec::match_group::Item {
diff --git a/vendor/gix/src/clone/mod.rs b/vendor/gix/src/clone/mod.rs
index 9ec226135..8afc3b99b 100644
--- a/vendor/gix/src/clone/mod.rs
+++ b/vendor/gix/src/clone/mod.rs
@@ -68,20 +68,37 @@ impl PrepareFetch {
url: Url,
path: impl AsRef<std::path::Path>,
kind: crate::create::Kind,
- mut create_opts: crate::create::Options,
+ create_opts: crate::create::Options,
open_opts: crate::open::Options,
) -> Result<Self, Error>
where
Url: TryInto<gix_url::Url, Error = E>,
gix_url::parse::Error: From<E>,
{
- let mut url = url.try_into().map_err(gix_url::parse::Error::from)?;
- url.canonicalize().map_err(|err| Error::CanonicalizeUrl {
- url: url.clone(),
- source: err,
- })?;
+ Self::new_inner(
+ url.try_into().map_err(gix_url::parse::Error::from)?,
+ path.as_ref(),
+ kind,
+ create_opts,
+ open_opts,
+ )
+ }
+
+ #[allow(clippy::result_large_err)]
+ fn new_inner(
+ mut url: gix_url::Url,
+ path: &std::path::Path,
+ kind: crate::create::Kind,
+ mut create_opts: crate::create::Options,
+ open_opts: crate::open::Options,
+ ) -> Result<Self, Error> {
create_opts.destination_must_be_empty = true;
let mut repo = crate::ThreadSafeRepository::init_opts(path, kind, create_opts, open_opts)?.to_thread_local();
+ url.canonicalize(repo.options.current_dir_or_empty())
+ .map_err(|err| Error::CanonicalizeUrl {
+ url: url.clone(),
+ source: err,
+ })?;
if repo.committer().is_none() {
let mut config = gix_config::File::new(gix_config::file::Metadata::api());
config
@@ -121,6 +138,7 @@ impl PrepareFetch {
/// A utility to collect configuration on how to perform a checkout into a working tree, and when dropped without checking out successfully
/// the fetched repository will be dropped.
#[must_use]
+#[cfg(feature = "worktree-mutation")]
pub struct PrepareCheckout {
/// A freshly initialized repository which is owned by us, or `None` if it was handed to the user
pub(self) repo: Option<crate::Repository>,
@@ -164,4 +182,5 @@ mod access_feat {
pub mod fetch;
///
+#[cfg(feature = "worktree-mutation")]
pub mod checkout;