diff options
Diffstat (limited to 'vendor/gix-worktree/src/cache')
-rw-r--r-- | vendor/gix-worktree/src/cache/delegate.rs | 3 | ||||
-rw-r--r-- | vendor/gix-worktree/src/cache/mod.rs | 2 | ||||
-rw-r--r-- | vendor/gix-worktree/src/cache/platform.rs | 2 | ||||
-rw-r--r-- | vendor/gix-worktree/src/cache/state/attributes.rs | 44 | ||||
-rw-r--r-- | vendor/gix-worktree/src/cache/state/ignore.rs | 13 | ||||
-rw-r--r-- | vendor/gix-worktree/src/cache/state/mod.rs | 5 |
6 files changed, 43 insertions, 26 deletions
diff --git a/vendor/gix-worktree/src/cache/delegate.rs b/vendor/gix-worktree/src/cache/delegate.rs index 90a141b0d..64b5a9bab 100644 --- a/vendor/gix-worktree/src/cache/delegate.rs +++ b/vendor/gix-worktree/src/cache/delegate.rs @@ -1,5 +1,4 @@ -use crate::cache::State; -use crate::PathIdMapping; +use crate::{cache::State, PathIdMapping}; /// Various aggregate numbers related to the stack delegate itself. #[derive(Default, Clone, Copy, Debug)] diff --git a/vendor/gix-worktree/src/cache/mod.rs b/vendor/gix-worktree/src/cache/mod.rs index 7984b2c4c..b3ccc6bac 100644 --- a/vendor/gix-worktree/src/cache/mod.rs +++ b/vendor/gix-worktree/src/cache/mod.rs @@ -53,7 +53,7 @@ impl Cache { /// `state` defines the capabilities of the cache. /// The `case` configures attribute and exclusion case sensitivity at *query time*, which should match the case that /// `state` might be configured with. - /// `buf` is used when reading files, and `id_mappings` should have been created with [State::id_mappings_from_index()]. + /// `buf` is used when reading files, and `id_mappings` should have been created with [`State::id_mappings_from_index()`]. pub fn new( worktree_root: impl Into<PathBuf>, state: State, diff --git a/vendor/gix-worktree/src/cache/platform.rs b/vendor/gix-worktree/src/cache/platform.rs index f52b53205..27d0bfbc8 100644 --- a/vendor/gix-worktree/src/cache/platform.rs +++ b/vendor/gix-worktree/src/cache/platform.rs @@ -28,7 +28,7 @@ impl<'a> Platform<'a> { /// # Panics /// /// If the cache was configured without exclude patterns. - pub fn matching_exclude_pattern(&self) -> Option<gix_ignore::search::Match<'_, ()>> { + pub fn matching_exclude_pattern(&self) -> Option<gix_ignore::search::Match<'_>> { let ignore = self.parent.state.ignore_or_panic(); let relative_path = gix_path::to_unix_separators_on_windows(gix_path::into_bstr(self.parent.stack.current_relative())); diff --git a/vendor/gix-worktree/src/cache/state/attributes.rs b/vendor/gix-worktree/src/cache/state/attributes.rs index 64316b35b..c42e36f74 100644 --- a/vendor/gix-worktree/src/cache/state/attributes.rs +++ b/vendor/gix-worktree/src/cache/state/attributes.rs @@ -1,10 +1,12 @@ use std::path::{Path, PathBuf}; -use crate::{Cache, PathIdMapping}; +use bstr::{BStr, ByteSlice}; use gix_glob::pattern::Case; -use crate::cache::state::{AttributeMatchGroup, Attributes}; -use bstr::{BStr, ByteSlice}; +use crate::{ + cache::state::{AttributeMatchGroup, Attributes}, + Cache, PathIdMapping, +}; /// Various aggregate numbers related [`Attributes`]. #[derive(Default, Clone, Copy, Debug)] @@ -45,7 +47,7 @@ pub enum Source { /// Initialization impl Attributes { /// Create a new instance from an attribute match group that represents `globals`. It can more easily be created with - /// [AttributeMatchGroup::new_globals()]. + /// [`AttributeMatchGroup::new_globals()`]. /// /// * `globals` contribute first and consist of all globally available, static files. /// * `info_attributes` is a path that should refer to `.git/info/attributes`, and it's not an error if the file doesn't exist. @@ -92,6 +94,7 @@ impl Attributes { let attr_file_in_index = id_mappings.binary_search_by(|t| t.0.as_bstr().cmp(attr_path_relative.as_ref())); // Git does not follow symbolic links as per documentation. let no_follow_symlinks = false; + let read_macros_as_dir_is_root = root == dir; let mut added = false; match self.source { @@ -100,8 +103,13 @@ impl Attributes { let blob = find(&id_mappings[idx].1, buf) .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; let attr_path = gix_path::from_bstring(attr_path_relative.into_owned()); - self.stack - .add_patterns_buffer(blob.data, attr_path, Some(Path::new("")), &mut self.collection); + self.stack.add_patterns_buffer( + blob.data, + attr_path, + Some(Path::new("")), + &mut self.collection, + read_macros_as_dir_is_root, + ); added = true; stats.patterns_buffers += 1; } @@ -112,6 +120,7 @@ impl Attributes { Some(root), buf, &mut self.collection, + read_macros_as_dir_is_root, )?; stats.pattern_files += usize::from(added); stats.tried_pattern_files += 1; @@ -124,6 +133,7 @@ impl Attributes { Some(root), buf, &mut self.collection, + read_macros_as_dir_is_root, )?; stats.pattern_files += usize::from(added); stats.tried_pattern_files += 1; @@ -131,8 +141,13 @@ impl Attributes { let blob = find(&id_mappings[idx].1, buf) .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; let attr_path = gix_path::from_bstring(attr_path_relative.into_owned()); - self.stack - .add_patterns_buffer(blob.data, attr_path, Some(Path::new("")), &mut self.collection); + self.stack.add_patterns_buffer( + blob.data, + attr_path, + Some(Path::new("")), + &mut self.collection, + read_macros_as_dir_is_root, + ); added = true; stats.patterns_buffers += 1; } @@ -142,15 +157,20 @@ impl Attributes { // Need one stack level per component so push and pop matches, but only if this isn't the root level which is never popped. if !added && self.info_attributes.is_none() { self.stack - .add_patterns_buffer(&[], Path::new("<empty dummy>"), None, &mut self.collection) + .add_patterns_buffer(&[], Path::new("<empty dummy>"), None, &mut self.collection, true) } // When reading the root, always the first call, we can try to also read the `.git/info/attributes` file which is // by nature never popped, and follows the root, as global. if let Some(info_attr) = self.info_attributes.take() { - let added = self - .stack - .add_patterns_file(info_attr, true, None, buf, &mut self.collection)?; + let added = self.stack.add_patterns_file( + info_attr, + true, + None, + buf, + &mut self.collection, + true, /* read macros */ + )?; stats.pattern_files += usize::from(added); stats.tried_pattern_files += 1; } diff --git a/vendor/gix-worktree/src/cache/state/ignore.rs b/vendor/gix-worktree/src/cache/state/ignore.rs index 5ff4ccd42..dde98da55 100644 --- a/vendor/gix-worktree/src/cache/state/ignore.rs +++ b/vendor/gix-worktree/src/cache/state/ignore.rs @@ -1,10 +1,13 @@ use std::path::Path; -use crate::cache::state::Ignore; -use crate::{cache::state::IgnoreMatchGroup, PathIdMapping}; use bstr::{BStr, ByteSlice}; use gix_glob::pattern::Case; +use crate::{ + cache::state::{Ignore, IgnoreMatchGroup}, + PathIdMapping, +}; + /// Decide where to read `.gitignore` files from. #[derive(Default, Debug, Clone, Copy)] pub enum Source { @@ -52,8 +55,7 @@ impl Ignore { stack: Default::default(), matched_directory_patterns_stack: Vec::with_capacity(6), exclude_file_name_for_directories: exclude_file_name_for_directories - .map(ToOwned::to_owned) - .unwrap_or_else(|| ".gitignore".into()), + .map_or_else(|| ".gitignore".into(), ToOwned::to_owned), source, } } @@ -74,7 +76,7 @@ impl Ignore { relative_path: &BStr, is_dir: Option<bool>, case: Case, - ) -> Option<gix_ignore::search::Match<'_, ()>> { + ) -> Option<gix_ignore::search::Match<'_>> { let groups = self.match_groups(); let mut dir_match = None; if let Some((source, mapping)) = self @@ -90,7 +92,6 @@ impl Ignore { { let match_ = gix_ignore::search::Match { pattern: &mapping.pattern, - value: &mapping.value, sequence_number: mapping.sequence_number, source, }; diff --git a/vendor/gix-worktree/src/cache/state/mod.rs b/vendor/gix-worktree/src/cache/state/mod.rs index ae2c6bafd..bdf504568 100644 --- a/vendor/gix-worktree/src/cache/state/mod.rs +++ b/vendor/gix-worktree/src/cache/state/mod.rs @@ -125,10 +125,7 @@ impl State { // Stage 0 means there is no merge going on, stage 2 means it's 'our' side of the merge, but then // there won't be a stage 0. if entry.mode == gix_index::entry::Mode::FILE && (entry.stage() == 0 || entry.stage() == 2) { - let basename = path - .rfind_byte(b'/') - .map(|pos| path[pos + 1..].as_bstr()) - .unwrap_or(path); + let basename = path.rfind_byte(b'/').map_or(path, |pos| path[pos + 1..].as_bstr()); let is_ignore = names.iter().find_map(|t| { match case { Case::Sensitive => basename == t.0, |