diff --git a/Cargo.lock b/Cargo.lock index bc8cb1be423..48e8e4da16c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1240,6 +1240,7 @@ dependencies = [ "gix-utils 0.1.5", "gix-validate 0.8.0", "gix-worktree 0.24.0", + "gix-worktree-state", "gix-worktree-stream", "is_ci", "log", diff --git a/gitoxide-core/src/hours/core.rs b/gitoxide-core/src/hours/core.rs index ddc6c4dbb28..eb033f954aa 100644 --- a/gitoxide-core/src/hours/core.rs +++ b/gitoxide-core/src/hours/core.rs @@ -101,8 +101,8 @@ pub fn spawn_tree_delta_threads<'scope>( repo.index_or_load_from_head().map_err(Into::into).and_then(|index| { repo.attributes( &index, - gix::worktree::cache::state::attributes::Source::IdMapping, - gix::worktree::cache::state::ignore::Source::IdMapping, + gix::worktree::stack::state::attributes::Source::IdMapping, + gix::worktree::stack::state::ignore::Source::IdMapping, None, ) .map_err(Into::into) diff --git a/gitoxide-core/src/index/checkout.rs b/gitoxide-core/src/index/checkout.rs index d28423e485b..bdfaa3235f0 100644 --- a/gitoxide-core/src/index/checkout.rs +++ b/gitoxide-core/src/index/checkout.rs @@ -4,7 +4,7 @@ use std::{ }; use anyhow::bail; -use gix::{odb::FindExt, worktree::checkout, Progress}; +use gix::{odb::FindExt, worktree::state::checkout, Progress}; use crate::{ index, @@ -55,7 +55,7 @@ pub fn checkout_exclusive( progress.info(format!("Skipping {num_skipped} DIR/SYMLINK/COMMIT entries")); } - let opts = gix::worktree::checkout::Options { + let opts = gix::worktree::state::checkout::Options { fs: gix::fs::Capabilities::probe(dest_directory), destination_is_initially_empty: true, @@ -86,7 +86,7 @@ pub fn checkout_exclusive( delayed_paths_unknown, delayed_paths_unprocessed, } = match repo { - Some(repo) => gix::worktree::checkout( + Some(repo) => gix::worktree::state::checkout( &mut index, dest_directory, { @@ -109,7 +109,7 @@ pub fn checkout_exclusive( should_interrupt, opts, ), - None => gix::worktree::checkout( + None => gix::worktree::state::checkout( &mut index, dest_directory, |_, buf| { diff --git a/gitoxide-core/src/repository/attributes/query.rs b/gitoxide-core/src/repository/attributes/query.rs index bb90aeccff3..ec777183ee7 100644 --- a/gitoxide-core/src/repository/attributes/query.rs +++ b/gitoxide-core/src/repository/attributes/query.rs @@ -89,16 +89,16 @@ pub(crate) mod function { pub(crate) fn attributes_cache( repo: &gix::Repository, -) -> anyhow::Result<(gix::worktree::Cache, IndexPersistedOrInMemory)> { +) -> anyhow::Result<(gix::worktree::Stack, IndexPersistedOrInMemory)> { let index = repo.index_or_load_from_head()?; let cache = repo.attributes( &index, if repo.is_bare() { - gix::worktree::cache::state::attributes::Source::IdMapping + gix::worktree::stack::state::attributes::Source::IdMapping } else { - gix::worktree::cache::state::attributes::Source::WorktreeThenIdMapping + gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping }, - gix::worktree::cache::state::ignore::Source::IdMapping, + gix::worktree::stack::state::ignore::Source::IdMapping, None, )?; Ok((cache, index)) diff --git a/gitoxide-core/src/repository/clone.rs b/gitoxide-core/src/repository/clone.rs index 7e0530ef899..6fec5801335 100644 --- a/gitoxide-core/src/repository/clone.rs +++ b/gitoxide-core/src/repository/clone.rs @@ -111,7 +111,7 @@ pub(crate) mod function { } }; - if let Some(gix::worktree::checkout::Outcome { collisions, errors, .. }) = outcome { + if let Some(gix::worktree::state::checkout::Outcome { collisions, errors, .. }) = outcome { if !(collisions.is_empty() && errors.is_empty()) { let mut messages = Vec::new(); if !errors.is_empty() { diff --git a/gitoxide-core/src/repository/index/entries.rs b/gitoxide-core/src/repository/index/entries.rs index 5b808db085d..9a0a2825d0d 100644 --- a/gitoxide-core/src/repository/index/entries.rs +++ b/gitoxide-core/src/repository/index/entries.rs @@ -56,22 +56,22 @@ pub(crate) mod function { match attrs { Attributes::WorktreeAndIndex => { if repo.is_bare() { - gix::worktree::cache::state::attributes::Source::IdMapping + gix::worktree::stack::state::attributes::Source::IdMapping } else { - gix::worktree::cache::state::attributes::Source::WorktreeThenIdMapping + gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping } } - Attributes::Index => gix::worktree::cache::state::attributes::Source::IdMapping, + Attributes::Index => gix::worktree::stack::state::attributes::Source::IdMapping, }, match attrs { Attributes::WorktreeAndIndex => { if repo.is_bare() { - gix::worktree::cache::state::ignore::Source::IdMapping + gix::worktree::stack::state::ignore::Source::IdMapping } else { - gix::worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped + gix::worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped } } - Attributes::Index => gix::worktree::cache::state::ignore::Source::IdMapping, + Attributes::Index => gix::worktree::stack::state::ignore::Source::IdMapping, }, None, ) @@ -203,7 +203,7 @@ pub(crate) mod function { pub excluded: usize, pub with_attributes: usize, pub max_attributes_per_path: usize, - pub cache: Option, + pub cache: Option, } #[cfg(feature = "serde")] diff --git a/gix-archive/tests/archive.rs b/gix-archive/tests/archive.rs index 1a91937ddc6..3eff24c7570 100644 --- a/gix-archive/tests/archive.rs +++ b/gix-archive/tests/archive.rs @@ -11,7 +11,7 @@ mod from_tree { use gix_object::tree::EntryMode; use gix_odb::FindExt; use gix_testtools::bstr::ByteSlice; - use gix_worktree::cache::state::attributes::Source; + use gix_worktree::stack::state::attributes::Source; use crate::hex_to_id; @@ -284,7 +284,7 @@ mod from_tree { Ok(()) } - fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Cache)> { + fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Stack)> { let dir = gix_testtools::scripted_fixture_read_only("basic.sh")?; let head = { @@ -295,14 +295,14 @@ mod from_tree { let mut collection = Default::default(); let mut buf = Default::default(); - let attributes = gix_worktree::cache::state::Attributes::new( + let attributes = gix_worktree::stack::state::Attributes::new( gix_attributes::Search::new_globals(None::, &mut buf, &mut collection)?, None, Source::WorktreeThenIdMapping, collection, ); - let state = gix_worktree::cache::State::AttributesStack(attributes); - let cache = gix_worktree::Cache::new(&dir, state, Case::Sensitive, Default::default(), Default::default()); + let state = gix_worktree::stack::State::AttributesStack(attributes); + let cache = gix_worktree::Stack::new(&dir, state, Case::Sensitive, Default::default(), Default::default()); Ok((dir, head, odb.into_arc()?, cache)) } diff --git a/gix-filter/tests/pipeline/mod.rs b/gix-filter/tests/pipeline/mod.rs index ba683564f4d..7db3224357d 100644 --- a/gix-filter/tests/pipeline/mod.rs +++ b/gix-filter/tests/pipeline/mod.rs @@ -17,22 +17,22 @@ fn default() -> crate::Result { Ok(()) } -fn attribute_cache(name: &str) -> gix_testtools::Result { +fn attribute_cache(name: &str) -> gix_testtools::Result { let dir = gix_testtools::scripted_fixture_read_only("pipeline_repos.sh")?.join(name); - Ok(gix_worktree::Cache::new( + Ok(gix_worktree::Stack::new( dir, - gix_worktree::cache::State::for_add( - gix_worktree::cache::state::Attributes::new( + gix_worktree::stack::State::for_add( + gix_worktree::stack::state::Attributes::new( Default::default(), None, - gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping, + gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping, Default::default(), ), - gix_worktree::cache::state::Ignore::new( + gix_worktree::stack::state::Ignore::new( Default::default(), Default::default(), None, - gix_worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, + gix_worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, ), ), Case::Sensitive, @@ -49,7 +49,7 @@ fn pipeline( gix_filter::pipeline::CrlfRoundTripCheck, eol::Configuration, ), -) -> gix_testtools::Result<(gix_worktree::Cache, gix_filter::Pipeline)> { +) -> gix_testtools::Result<(gix_worktree::Stack, gix_filter::Pipeline)> { let cache = attribute_cache(name)?; let (drivers, encodings_with_roundtrip_check, crlf_roundtrip_check, eol_config) = init(); let pipe = gix_filter::Pipeline::new( diff --git a/gix-status/src/index_as_worktree/types.rs b/gix-status/src/index_as_worktree/types.rs index 3d488d24ef4..10ff5c28d24 100644 --- a/gix-status/src/index_as_worktree/types.rs +++ b/gix-status/src/index_as_worktree/types.rs @@ -1,6 +1,6 @@ use bstr::BStr; -/// The error returned by [`status()`][crate::status()]. +/// The error returned by [`status()`](crate::index_as_worktree()). #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum Error { @@ -40,7 +40,7 @@ pub enum Change { /// Indicates that one of the stat changes was an executable bit change /// which is a significant change itself. executable_bit_changed: bool, - /// The output of the [`CompareBlobs`][crate::status::content::CompareBlobs] run on this entry. + /// The output of the [`CompareBlobs`](crate::index_as_worktree::content::CompareBlobs) run on this entry. /// If there is no content change and only the executable bit /// changed than this is `None`. content_change: Option, diff --git a/gix-worktree-state/src/checkout/chunk.rs b/gix-worktree-state/src/checkout/chunk.rs index 445ed9a9680..46d09bac28c 100644 --- a/gix-worktree-state/src/checkout/chunk.rs +++ b/gix-worktree-state/src/checkout/chunk.rs @@ -7,7 +7,7 @@ use bstr::{BStr, BString}; use gix_hash::oid; use crate::{checkout, checkout::entry}; -use gix_worktree::Cache; +use gix_worktree::Stack; mod reduce { use std::marker::PhantomData; @@ -92,7 +92,7 @@ pub struct Outcome<'a> { #[derive(Clone)] pub struct Context { pub find: Find, - pub path_cache: Cache, + pub path_cache: Stack, pub filters: gix_filter::Pipeline, pub buf: Vec, pub options: Options, diff --git a/gix-worktree-state/src/checkout/entry.rs b/gix-worktree-state/src/checkout/entry.rs index e699d948958..68cb796aa54 100644 --- a/gix-worktree-state/src/checkout/entry.rs +++ b/gix-worktree-state/src/checkout/entry.rs @@ -10,11 +10,11 @@ use gix_hash::oid; use gix_index::{entry::Stat, Entry}; use io_close::Close; -use gix_worktree::Cache; +use gix_worktree::Stack; pub struct Context<'a, Find> { pub find: &'a mut Find, - pub path_cache: &'a mut Cache, + pub path_cache: &'a mut Stack, pub filters: &'a mut gix_filter::Pipeline, pub buf: &'a mut Vec, } diff --git a/gix-worktree-state/src/checkout/function.rs b/gix-worktree-state/src/checkout/function.rs index ba825e8431a..b29a6e69356 100644 --- a/gix-worktree-state/src/checkout/function.rs +++ b/gix-worktree-state/src/checkout/function.rs @@ -4,7 +4,7 @@ use gix_features::{interrupt, parallel::in_parallel_with_finalize, progress::Pro use gix_hash::oid; use crate::checkout::chunk; -use gix_worktree::{cache, Cache}; +use gix_worktree::{stack, Stack}; /// Checkout the entire `index` into `dir`, and resolve objects found in index entries with `find` to write their content to their /// respective path in `dir`. @@ -66,12 +66,12 @@ where None, ); - let state = cache::State::for_checkout(options.overwrite_existing, std::mem::take(&mut options.attributes)); + let state = stack::State::for_checkout(options.overwrite_existing, std::mem::take(&mut options.attributes)); let attribute_files = state.id_mappings_from_index(index, paths, case); let mut ctx = chunk::Context { buf: Vec::new(), options: (&options).into(), - path_cache: Cache::new(dir, state, case, Vec::with_capacity(512), attribute_files), + path_cache: Stack::new(dir, state, case, Vec::with_capacity(512), attribute_files), filters: options.filters, find, }; diff --git a/gix-worktree-state/src/checkout/mod.rs b/gix-worktree-state/src/checkout/mod.rs index e01f7bff74a..70e46c84e2e 100644 --- a/gix-worktree-state/src/checkout/mod.rs +++ b/gix-worktree-state/src/checkout/mod.rs @@ -60,7 +60,7 @@ pub struct Options { /// Control how stat comparisons are made when checking if a file is fresh. pub stat_options: stat::Options, /// A stack of attributes to use with the filesystem cache to use as driver for filters. - pub attributes: gix_worktree::cache::state::Attributes, + pub attributes: gix_worktree::stack::state::Attributes, /// The filter pipeline to use for applying mandatory filters before writing to the worktree. pub filters: gix_filter::Pipeline, /// Control how long-running processes may use the 'delay' capability. diff --git a/gix-worktree-state/tests/state/checkout.rs b/gix-worktree-state/tests/state/checkout.rs index 52e453dd23e..ff06812b528 100644 --- a/gix-worktree-state/tests/state/checkout.rs +++ b/gix-worktree-state/tests/state/checkout.rs @@ -11,7 +11,7 @@ use gix_features::progress; use gix_object::bstr::ByteSlice; use gix_odb::FindExt; use gix_testtools::tempfile::TempDir; -use gix_worktree::checkout::Collision; +use gix_worktree_state::checkout::Collision; use once_cell::sync::Lazy; use crate::fixture_path; @@ -454,18 +454,18 @@ pub fn dir_structure>(path: P) -> Vec crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree::checkout::Outcome)> { +) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree_state::checkout::Outcome)> { checkout_index_in_tmp_dir_opts(opts, name, |_d| true, |_| Ok(())) } fn checkout_index_in_tmp_dir_opts( - opts: gix_worktree::checkout::Options, + opts: gix_worktree_state::checkout::Options, name: &str, mut allow_return_object: impl FnMut(&gix_hash::oid) -> bool + Send + Clone, prep_dest: impl Fn(&Path) -> std::io::Result<()>, -) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree::checkout::Outcome)> { +) -> crate::Result<(PathBuf, TempDir, gix_index::File, gix_worktree_state::checkout::Outcome)> { let source_tree = fixture_path(name); let git_dir = source_tree.join(".git"); let mut index = gix_index::File::at(git_dir.join("index"), gix_hash::Kind::Sha1, Default::default())?; @@ -473,7 +473,7 @@ fn checkout_index_in_tmp_dir_opts( let destination = gix_testtools::tempfile::tempdir_in(std::env::current_dir()?)?; prep_dest(destination.path()).expect("preparation must succeed"); - let outcome = gix_worktree::checkout( + let outcome = gix_worktree_state::checkout( &mut index, destination.path(), move |oid, buf| { @@ -501,8 +501,8 @@ fn probe_gitoxide_dir() -> crate::Result { )) } -fn opts_from_probe() -> gix_worktree::checkout::Options { - gix_worktree::checkout::Options { +fn opts_from_probe() -> gix_worktree_state::checkout::Options { + gix_worktree_state::checkout::Options { fs: probe_gitoxide_dir().unwrap(), destination_is_initially_empty: true, thread_limit: gix_features::parallel::num_threads(None).into(), diff --git a/gix-worktree-stream/tests/stream.rs b/gix-worktree-stream/tests/stream.rs index e70c5b11837..22561bb7076 100644 --- a/gix-worktree-stream/tests/stream.rs +++ b/gix-worktree-stream/tests/stream.rs @@ -15,7 +15,7 @@ mod from_tree { use gix_object::{bstr::ByteSlice, tree::EntryMode}; use gix_odb::FindExt; use gix_testtools::once_cell::sync::Lazy; - use gix_worktree::cache::state::attributes::Source; + use gix_worktree::stack::state::attributes::Source; use crate::hex_to_id; @@ -231,7 +231,7 @@ mod from_tree { Ok(()) } - fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Cache)> { + fn basic() -> gix_testtools::Result<(PathBuf, gix_hash::ObjectId, gix_odb::HandleArc, gix_worktree::Stack)> { let dir = gix_testtools::scripted_fixture_read_only("basic.sh")?; let head = { @@ -242,14 +242,14 @@ mod from_tree { let mut collection = Default::default(); let mut buf = Default::default(); - let attributes = gix_worktree::cache::state::Attributes::new( + let attributes = gix_worktree::stack::state::Attributes::new( gix_attributes::Search::new_globals(None::, &mut buf, &mut collection)?, None, Source::WorktreeThenIdMapping, collection, ); - let state = gix_worktree::cache::State::AttributesStack(attributes); - let cache = gix_worktree::Cache::new(&dir, state, Case::Sensitive, Default::default(), Default::default()); + let state = gix_worktree::stack::State::AttributesStack(attributes); + let cache = gix_worktree::Stack::new(&dir, state, Case::Sensitive, Default::default(), Default::default()); Ok((dir, head, odb.into_arc()?, cache)) } diff --git a/gix-worktree/src/stack/mod.rs b/gix-worktree/src/stack/mod.rs index d38adefa1e4..6892f99025d 100644 --- a/gix-worktree/src/stack/mod.rs +++ b/gix-worktree/src/stack/mod.rs @@ -81,7 +81,7 @@ impl Stack { /// symlinks are in that path. /// Unless `is_dir` is known with `Some(…)`, then `relative` points to a directory itself in which case the entire resulting /// path is created as directory. If it's not known it is assumed to be a file. - /// `find` maybe used to lookup objects from an [id mapping][crate::cache::State::id_mappings_from_index()], with mappnigs + /// `find` maybe used to lookup objects from an [id mapping][crate::stack::State::id_mappings_from_index()], with mappnigs /// /// Provide access to cached information for that `relative` path via the returned platform. pub fn at_path( @@ -110,7 +110,7 @@ impl Stack { /// Obtain a platform for lookups from a repo-`relative` path, typically obtained from an index entry. `is_dir` should reflect /// whether it's a directory or not, or left at `None` if unknown. - /// `find` maybe used to lookup objects from an [id mapping][crate::cache::State::id_mappings_from_index()]. + /// `find` maybe used to lookup objects from an [id mapping][crate::stack::State::id_mappings_from_index()]. /// All effects are similar to [`at_path()`][Self::at_path()]. /// /// If `relative` ends with `/` and `is_dir` is `None`, it is automatically assumed to be a directory. diff --git a/gix-worktree/src/stack/state/attributes.rs b/gix-worktree/src/stack/state/attributes.rs index 79b05edc44b..ea6b0f61a30 100644 --- a/gix-worktree/src/stack/state/attributes.rs +++ b/gix-worktree/src/stack/state/attributes.rs @@ -23,7 +23,7 @@ pub struct Statistics { /// Decide where to read `.gitattributes` files from. /// /// To Retrieve attribute files from id mappings, see -/// [State::id_mappings_from_index()][crate::cache::State::id_mappings_from_index()]. +/// [State::id_mappings_from_index()][crate::stack::State::id_mappings_from_index()]. /// /// These mappings are typically produced from an index. /// If a tree should be the source, build an attribute list from a tree instead, or convert a tree to an index. @@ -230,7 +230,7 @@ impl Stack { } /// Return the metadata collection that enables initializing attribute match outcomes as done in - /// [`attribute_matches()`][Cache::attribute_matches()] or [`selected_attribute_matches()`][Cache::selected_attribute_matches()] + /// [`attribute_matches()`][Stack::attribute_matches()] or [`selected_attribute_matches()`][Stack::selected_attribute_matches()] /// /// ### Panics /// diff --git a/gix-worktree/src/stack/state/ignore.rs b/gix-worktree/src/stack/state/ignore.rs index 2dbddc520fd..0945a3c9403 100644 --- a/gix-worktree/src/stack/state/ignore.rs +++ b/gix-worktree/src/stack/state/ignore.rs @@ -12,7 +12,7 @@ use crate::{ #[derive(Default, Debug, Clone, Copy)] pub enum Source { /// Retrieve ignore files from id mappings, see - /// [State::id_mappings_from_index()][crate::cache::State::id_mappings_from_index()]. + /// [State::id_mappings_from_index()][crate::stack::State::id_mappings_from_index()]. /// /// These mappings are typically produced from an index. /// If a tree should be the source, build an attribute list from a tree instead, or convert a tree to an index. diff --git a/gix/Cargo.toml b/gix/Cargo.toml index b3bd08d53a1..703c9c8e989 100644 --- a/gix/Cargo.toml +++ b/gix/Cargo.toml @@ -162,6 +162,7 @@ gix-credentials = { version = "^0.17.1", path = "../gix-credentials" } gix-prompt = { version = "^0.5.5", path = "../gix-prompt" } gix-index = { version = "^0.22.0", path = "../gix-index" } gix-worktree = { version = "^0.24.0", path = "../gix-worktree" } +gix-worktree-state = { version = "^0.1.0", path = "../gix-worktree-state" } gix-hashtable = { version = "^0.2.4", path = "../gix-hashtable" } gix-commitgraph = { version = "^0.18.2", path = "../gix-commitgraph" } gix-pathspec = { version = "^0.1.0", path = "../gix-pathspec" } diff --git a/gix/src/clone/checkout.rs b/gix/src/clone/checkout.rs index 8657f9a3aa9..a51b7197146 100644 --- a/gix/src/clone/checkout.rs +++ b/gix/src/clone/checkout.rs @@ -27,7 +27,8 @@ pub mod main_worktree { CheckoutOptions(#[from] crate::config::checkout_options::Error), #[error(transparent)] IndexCheckout( - #[from] gix_worktree::checkout::Error>, + #[from] + gix_worktree_state::checkout::Error>, ), #[error("Failed to reopen object database as Arc (only if thread-safety wasn't compiled in)")] OpenArcOdb(#[from] std::io::Error), @@ -68,7 +69,7 @@ pub mod main_worktree { &mut self, mut progress: impl crate::Progress, should_interrupt: &AtomicBool, - ) -> Result<(Repository, gix_worktree::checkout::Outcome), Error> { + ) -> Result<(Repository, gix_worktree_state::checkout::Outcome), Error> { let _span = gix_trace::coarse!("gix::clone::PrepareCheckout::main_worktree()"); let repo = self .repo @@ -82,7 +83,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(), )) } }; @@ -95,7 +96,7 @@ pub mod main_worktree { let mut opts = repo .config - .checkout_options(repo, gix_worktree::cache::state::attributes::Source::IdMapping)?; + .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()); @@ -105,7 +106,7 @@ pub mod main_worktree { 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, { diff --git a/gix/src/config/cache/access.rs b/gix/src/config/cache/access.rs index 35220ce7644..7ca9be0d59c 100644 --- a/gix/src/config/cache/access.rs +++ b/gix/src/config/cache/access.rs @@ -160,8 +160,8 @@ impl Cache { pub(crate) fn checkout_options( &self, repo: &Repository, - attributes_source: gix_worktree::cache::state::attributes::Source, - ) -> Result { + attributes_source: gix_worktree::stack::state::attributes::Source, + ) -> Result { let git_dir = repo.git_dir(); let thread_limit = self.apply_leniency( self.resolved @@ -189,7 +189,7 @@ impl Cache { } else { gix_filter::driver::apply::Delay::Forbid }; - Ok(gix_worktree::checkout::Options { + Ok(gix_worktree_state::checkout::Options { filter_process_delay, filters, attributes: self @@ -219,14 +219,14 @@ impl Cache { &self, git_dir: &std::path::Path, overrides: Option, - source: gix_worktree::cache::state::ignore::Source, + source: gix_worktree::stack::state::ignore::Source, buf: &mut Vec, - ) -> Result { + ) -> Result { let excludes_file = match self.excludes_file().transpose()? { Some(user_path) => Some(user_path), None => self.xdg_config_path("ignore")?, }; - Ok(gix_worktree::cache::state::Ignore::new( + Ok(gix_worktree::stack::state::Ignore::new( overrides.unwrap_or_default(), gix_ignore::Search::from_git_dir(git_dir, excludes_file, buf)?, None, @@ -237,9 +237,9 @@ impl Cache { pub(crate) fn assemble_attribute_globals( &self, git_dir: &std::path::Path, - source: gix_worktree::cache::state::attributes::Source, + source: gix_worktree::stack::state::attributes::Source, attributes: crate::open::permissions::Attributes, - ) -> Result<(gix_worktree::cache::state::Attributes, Vec), config::attribute_stack::Error> { + ) -> Result<(gix_worktree::stack::state::Attributes, Vec), config::attribute_stack::Error> { let configured_or_user_attributes = match self .trusted_file_path("core", None, Core::ATTRIBUTES_FILE.name) .transpose()? @@ -265,7 +265,7 @@ impl Cache { let info_attributes_path = git_dir.join("info").join("attributes"); let mut buf = Vec::new(); let mut collection = gix_attributes::search::MetadataCollection::default(); - let state = gix_worktree::cache::state::Attributes::new( + let state = gix_worktree::stack::state::Attributes::new( gix_attributes::Search::new_globals(attribute_files, &mut buf, &mut collection)?, Some(info_attributes_path), source, diff --git a/gix/src/filter.rs b/gix/src/filter.rs index 073ea6328b9..27447e12bc7 100644 --- a/gix/src/filter.rs +++ b/gix/src/filter.rs @@ -67,7 +67,7 @@ pub mod pipeline { #[derive(Clone)] pub struct Pipeline<'repo> { inner: gix_filter::Pipeline, - cache: gix_worktree::Cache, + cache: gix_worktree::Stack, repo: &'repo Repository, } @@ -110,7 +110,7 @@ impl<'repo> Pipeline<'repo> { /// Create a new instance by extracting all necessary information and configuration from a `repo` along with `cache` for accessing /// attributes. The `index` is used for some filters which may access it under very specific circumstances. - pub fn new(repo: &'repo Repository, cache: gix_worktree::Cache) -> Result { + pub fn new(repo: &'repo Repository, cache: gix_worktree::Stack) -> Result { let pipeline = gix_filter::Pipeline::new(cache.attributes_collection(), Self::options(repo)?); Ok(Pipeline { inner: pipeline, @@ -120,7 +120,7 @@ impl<'repo> Pipeline<'repo> { } /// Detach the repository and obtain the individual functional parts. - pub fn into_parts(self) -> (gix_filter::Pipeline, gix_worktree::Cache) { + pub fn into_parts(self) -> (gix_filter::Pipeline, gix_worktree::Stack) { (self.inner, self.cache) } } diff --git a/gix/src/pathspec.rs b/gix/src/pathspec.rs index 16649898d2f..587aef4bf93 100644 --- a/gix/src/pathspec.rs +++ b/gix/src/pathspec.rs @@ -43,7 +43,7 @@ impl<'repo> Pathspec<'repo> { repo: &'repo Repository, patterns: impl IntoIterator>, inherit_ignore_case: bool, - make_attributes: impl FnOnce() -> Result>, + make_attributes: impl FnOnce() -> Result>, ) -> Result { let mut defaults = repo.pathspec_defaults()?; if inherit_ignore_case && repo.config.fs_capabilities()?.ignore_case { @@ -67,9 +67,9 @@ impl<'repo> Pathspec<'repo> { Ok(Self { repo, search, cache }) } /// Turn ourselves into the functional parts for direct usage. - /// Note that the [`cache`](gix_worktree::Cache) is only set if one of the [`search` patterns](Search) + /// Note that the [`cache`](gix_worktree::Stack) is only set if one of the [`search` patterns](Search) /// is specifying attributes to match for. - pub fn into_parts(self) -> (Search, Option) { + pub fn into_parts(self) -> (Search, Option) { (self.search, self.cache) } } @@ -77,7 +77,7 @@ impl<'repo> Pathspec<'repo> { /// Access impl<'repo> Pathspec<'repo> { /// Return the attributes cache which is used when matching attributes in pathspecs, or `None` if none of the pathspecs require that. - pub fn attributes(&self) -> Option<&gix_worktree::Cache> { + pub fn attributes(&self) -> Option<&gix_worktree::Stack> { self.cache.as_ref() } diff --git a/gix/src/repository/attributes.rs b/gix/src/repository/attributes.rs index 23fd65203d9..e875ef0b0d8 100644 --- a/gix/src/repository/attributes.rs +++ b/gix/src/repository/attributes.rs @@ -29,10 +29,10 @@ impl Repository { pub fn attributes( &self, index: &gix_index::State, - attributes_source: gix_worktree::cache::state::attributes::Source, - ignore_source: gix_worktree::cache::state::ignore::Source, + attributes_source: gix_worktree::stack::state::attributes::Source, + ignore_source: gix_worktree::stack::state::ignore::Source, exclude_overrides: Option, - ) -> Result { + ) -> Result { let case = if self.config.ignore_case { gix_glob::pattern::Case::Fold } else { @@ -46,9 +46,9 @@ impl Repository { let ignore = self.config .assemble_exclude_globals(self.git_dir(), exclude_overrides, ignore_source, &mut buf)?; - let state = gix_worktree::cache::State::AttributesAndIgnoreStack { attributes, ignore }; + let state = gix_worktree::stack::State::AttributesAndIgnoreStack { attributes, ignore }; let attribute_list = state.id_mappings_from_index(index, index.path_backing(), case); - Ok(gix_worktree::Cache::new( + Ok(gix_worktree::Stack::new( // this is alright as we don't cause mutation of that directory, it's virtual. self.work_dir().unwrap_or(self.git_dir()), state, @@ -62,8 +62,8 @@ impl Repository { pub fn attributes_only( &self, index: &gix_index::State, - attributes_source: gix_worktree::cache::state::attributes::Source, - ) -> Result { + attributes_source: gix_worktree::stack::state::attributes::Source, + ) -> Result { let case = if self.config.ignore_case { gix_glob::pattern::Case::Fold } else { @@ -74,9 +74,9 @@ impl Repository { attributes_source, self.options.permissions.attributes, )?; - let state = gix_worktree::cache::State::AttributesStack(attributes); + let state = gix_worktree::stack::State::AttributesStack(attributes); let attribute_list = state.id_mappings_from_index(index, index.path_backing(), case); - Ok(gix_worktree::Cache::new( + Ok(gix_worktree::Stack::new( // this is alright as we don't cause mutation of that directory, it's virtual. self.work_dir().unwrap_or(self.git_dir()), state, @@ -105,8 +105,8 @@ impl Repository { &self, index: &gix_index::State, overrides: Option, - source: gix_worktree::cache::state::ignore::Source, - ) -> Result { + source: gix_worktree::stack::state::ignore::Source, + ) -> Result { let case = if self.config.ignore_case { gix_glob::pattern::Case::Fold } else { @@ -116,9 +116,9 @@ impl Repository { let ignore = self .config .assemble_exclude_globals(self.git_dir(), overrides, source, &mut buf)?; - let state = gix_worktree::cache::State::IgnoreStack(ignore); + let state = gix_worktree::stack::State::IgnoreStack(ignore); let attribute_list = state.id_mappings_from_index(index, index.path_backing(), case); - Ok(gix_worktree::Cache::new( + Ok(gix_worktree::Stack::new( // this is alright as we don't cause mutation of that directory, it's virtual. self.work_dir().unwrap_or(self.git_dir()), state, diff --git a/gix/src/repository/filter.rs b/gix/src/repository/filter.rs index 77dd9005d62..6f08309ce0f 100644 --- a/gix/src/repository/filter.rs +++ b/gix/src/repository/filter.rs @@ -49,13 +49,13 @@ impl Repository { }, Ok, )?)?; - let cache = self.attributes_only(&index, gix_worktree::cache::state::attributes::Source::IdMapping)?; + let cache = self.attributes_only(&index, gix_worktree::stack::state::attributes::Source::IdMapping)?; (cache, IndexPersistedOrInMemory::InMemory(index)) } else { let index = self.index()?; let cache = self.attributes_only( &index, - gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping, + gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping, )?; (cache, IndexPersistedOrInMemory::Persisted(index)) }; diff --git a/gix/src/repository/pathspec.rs b/gix/src/repository/pathspec.rs index 5a7e8245fec..4b2ab8c331a 100644 --- a/gix/src/repository/pathspec.rs +++ b/gix/src/repository/pathspec.rs @@ -17,7 +17,7 @@ impl Repository { Pathspec::new(self, patterns, inherit_ignore_case, || { self.attributes_only( index, - gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping, + gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping, ) .map_err(Into::into) }) diff --git a/gix/src/repository/worktree.rs b/gix/src/repository/worktree.rs index c182e624342..b05c4fcbf48 100644 --- a/gix/src/repository/worktree.rs +++ b/gix/src/repository/worktree.rs @@ -74,7 +74,7 @@ impl crate::Repository { // TODO(perf): when loading a non-HEAD tree, we effectively traverse the tree twice. This is usually fast though, and sharing // an object cache between the copies of the ODB handles isn't trivial and needs a lock. let index = self.index_from_tree(&id)?; - let mut cache = self.attributes_only(&index, gix_worktree::cache::state::attributes::Source::IdMapping)?; + let mut cache = self.attributes_only(&index, gix_worktree::stack::state::attributes::Source::IdMapping)?; let pipeline = gix_filter::Pipeline::new(cache.attributes_collection(), crate::filter::Pipeline::options(self)?); let objects = self.objects.clone().into_arc().expect("TBD error handling"); diff --git a/gix/src/types.rs b/gix/src/types.rs index 581ea76e92b..076512a4b58 100644 --- a/gix/src/types.rs +++ b/gix/src/types.rs @@ -202,7 +202,7 @@ pub struct Remote<'repo> { pub struct Pathspec<'repo> { pub(crate) repo: &'repo Repository, /// The cache to power attribute access. It's only initialized if we have a pattern with attributes. - pub(crate) cache: Option, + pub(crate) cache: Option, /// The prepared search to use for checking matches. pub(crate) search: gix_pathspec::Search, } diff --git a/gix/src/worktree/mod.rs b/gix/src/worktree/mod.rs index 3fbdca49993..bd808373927 100644 --- a/gix/src/worktree/mod.rs +++ b/gix/src/worktree/mod.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; #[cfg(feature = "worktree-archive")] pub use gix_archive as archive; pub use gix_worktree::*; +pub use gix_worktree_state as state; #[cfg(feature = "worktree-stream")] pub use gix_worktree_stream as stream; @@ -120,12 +121,12 @@ pub mod excludes { /// /// When only excludes are desired, this is the most efficient way to obtain them. Otherwise use /// [`Worktree::attributes()`][crate::Worktree::attributes()] for accessing both attributes and excludes. - pub fn excludes(&self, overrides: Option) -> Result { + pub fn excludes(&self, overrides: Option) -> Result { let index = self.index()?; Ok(self.parent.excludes( &index, overrides, - gix_worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, + gix_worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, )?) } } @@ -150,23 +151,23 @@ pub mod attributes { /// /// * `$XDG_CONFIG_HOME/…/ignore|attributes` if `core.excludesFile|attributesFile` is *not* set, otherwise use the configured file. /// * `$GIT_DIR/info/exclude|attributes` if present. - pub fn attributes(&self, overrides: Option) -> Result { + pub fn attributes(&self, overrides: Option) -> Result { let index = self.index()?; Ok(self.parent.attributes( &index, - gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping, - gix_worktree::cache::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, + gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping, + gix_worktree::stack::state::ignore::Source::WorktreeThenIdMappingIfNotSkipped, overrides, )?) } /// Like [attributes()][Self::attributes()], but without access to exclude/ignore information. - pub fn attributes_only(&self) -> Result { + pub fn attributes_only(&self) -> Result { let index = self.index()?; self.parent .attributes_only( &index, - gix_worktree::cache::state::attributes::Source::WorktreeThenIdMapping, + gix_worktree::stack::state::attributes::Source::WorktreeThenIdMapping, ) .map_err(|err| Error::CreateCache(err.into())) }