summaryrefslogtreecommitdiffstats
path: root/vendor/gix-worktree/src/stack
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-worktree/src/stack
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-worktree/src/stack')
-rw-r--r--vendor/gix-worktree/src/stack/delegate.rs16
-rw-r--r--vendor/gix-worktree/src/stack/mod.rs29
-rw-r--r--vendor/gix-worktree/src/stack/state/attributes.rs10
-rw-r--r--vendor/gix-worktree/src/stack/state/ignore.rs10
4 files changed, 27 insertions, 38 deletions
diff --git a/vendor/gix-worktree/src/stack/delegate.rs b/vendor/gix-worktree/src/stack/delegate.rs
index 8e48057de..1234346c5 100644
--- a/vendor/gix-worktree/src/stack/delegate.rs
+++ b/vendor/gix-worktree/src/stack/delegate.rs
@@ -18,19 +18,13 @@ pub struct Statistics {
pub pop_directory: usize,
}
-pub(crate) type FindFn<'a> = dyn for<'b> FnMut(
- &gix_hash::oid,
- &'b mut Vec<u8>,
- ) -> Result<gix_object::BlobRef<'b>, Box<dyn std::error::Error + Send + Sync>>
- + 'a;
-
pub(crate) struct StackDelegate<'a, 'find> {
pub state: &'a mut State,
pub buf: &'a mut Vec<u8>,
#[cfg_attr(not(feature = "attributes"), allow(dead_code))]
pub is_dir: bool,
pub id_mappings: &'a Vec<PathIdMapping>,
- pub find: &'find mut FindFn<'find>,
+ pub objects: &'find dyn gix_object::Find,
pub case: gix_glob::pattern::Case,
pub statistics: &'a mut super::Statistics,
}
@@ -63,7 +57,7 @@ impl<'a, 'find> gix_fs::stack::Delegate for StackDelegate<'a, 'find> {
rela_dir,
self.buf,
self.id_mappings,
- self.find,
+ self.objects,
&mut self.statistics.attributes,
)?;
}
@@ -75,7 +69,7 @@ impl<'a, 'find> gix_fs::stack::Delegate for StackDelegate<'a, 'find> {
rela_dir,
self.buf,
self.id_mappings,
- &mut self.find,
+ self.objects,
&mut self.statistics.attributes,
)?;
ignore.push_directory(
@@ -84,7 +78,7 @@ impl<'a, 'find> gix_fs::stack::Delegate for StackDelegate<'a, 'find> {
rela_dir,
self.buf,
self.id_mappings,
- &mut self.find,
+ self.objects,
self.case,
&mut self.statistics.ignore,
)?
@@ -95,7 +89,7 @@ impl<'a, 'find> gix_fs::stack::Delegate for StackDelegate<'a, 'find> {
rela_dir,
self.buf,
self.id_mappings,
- &mut self.find,
+ self.objects,
self.case,
&mut self.statistics.ignore,
)?,
diff --git a/vendor/gix-worktree/src/stack/mod.rs b/vendor/gix-worktree/src/stack/mod.rs
index 228467f5b..b6c03d175 100644
--- a/vendor/gix-worktree/src/stack/mod.rs
+++ b/vendor/gix-worktree/src/stack/mod.rs
@@ -2,7 +2,6 @@
use std::path::{Path, PathBuf};
use bstr::{BStr, ByteSlice};
-use gix_hash::oid;
use super::Stack;
use crate::PathIdMapping;
@@ -106,26 +105,22 @@ 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::stack::State::id_mappings_from_index()], with mappnigs
+ /// `objects` 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<Find, E>(
+ pub fn at_path(
&mut self,
relative: impl AsRef<Path>,
is_dir: Option<bool>,
- mut find: Find,
- ) -> std::io::Result<Platform<'_>>
- where
- Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<gix_object::BlobRef<'a>, E>,
- E: std::error::Error + Send + Sync + 'static,
- {
+ objects: &dyn gix_object::Find,
+ ) -> std::io::Result<Platform<'_>> {
self.statistics.platforms += 1;
let mut delegate = StackDelegate {
state: &mut self.state,
buf: &mut self.buf,
is_dir: is_dir.unwrap_or(false),
id_mappings: &self.id_mappings,
- find: &mut |oid, buf| Ok(find(oid, buf).map_err(Box::new)?),
+ objects,
case: self.case,
statistics: &mut self.statistics,
};
@@ -136,7 +131,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::stack::State::id_mappings_from_index()].
+ /// `objects` 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.
@@ -144,23 +139,19 @@ impl Stack {
/// ### Panics
///
/// on illformed UTF8 in `relative`
- pub fn at_entry<'r, Find, E>(
+ pub fn at_entry<'r>(
&mut self,
relative: impl Into<&'r BStr>,
is_dir: Option<bool>,
- find: Find,
- ) -> std::io::Result<Platform<'_>>
- where
- Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Result<gix_object::BlobRef<'a>, E>,
- E: std::error::Error + Send + Sync + 'static,
- {
+ objects: &dyn gix_object::Find,
+ ) -> std::io::Result<Platform<'_>> {
let relative = relative.into();
let relative_path = gix_path::from_bstr(relative);
self.at_path(
relative_path,
is_dir.or_else(|| relative.ends_with_str("/").then_some(true)),
- find,
+ objects,
)
}
}
diff --git a/vendor/gix-worktree/src/stack/state/attributes.rs b/vendor/gix-worktree/src/stack/state/attributes.rs
index d49de1288..04ad8b5c7 100644
--- a/vendor/gix-worktree/src/stack/state/attributes.rs
+++ b/vendor/gix-worktree/src/stack/state/attributes.rs
@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
use bstr::{BStr, ByteSlice};
use gix_glob::pattern::Case;
+use gix_object::FindExt;
-use crate::stack::delegate::FindFn;
use crate::{
stack::state::{AttributeMatchGroup, Attributes},
PathIdMapping, Stack,
@@ -95,7 +95,7 @@ impl Attributes {
rela_dir: &BStr,
buf: &mut Vec<u8>,
id_mappings: &[PathIdMapping],
- find: &mut FindFn<'_>,
+ objects: &dyn gix_object::Find,
stats: &mut Statistics,
) -> std::io::Result<()> {
let attr_path_relative =
@@ -109,7 +109,8 @@ impl Attributes {
match self.source {
Source::IdMapping | Source::IdMappingThenWorktree => {
if let Ok(idx) = attr_file_in_index {
- let blob = find(&id_mappings[idx].1, buf)
+ let blob = objects
+ .find_blob(&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(
@@ -147,7 +148,8 @@ impl Attributes {
stats.pattern_files += usize::from(added);
stats.tried_pattern_files += 1;
if let Some(idx) = attr_file_in_index.ok().filter(|_| !added) {
- let blob = find(&id_mappings[idx].1, buf)
+ let blob = objects
+ .find_blob(&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(
diff --git a/vendor/gix-worktree/src/stack/state/ignore.rs b/vendor/gix-worktree/src/stack/state/ignore.rs
index e2a2d5a3d..370459053 100644
--- a/vendor/gix-worktree/src/stack/state/ignore.rs
+++ b/vendor/gix-worktree/src/stack/state/ignore.rs
@@ -2,8 +2,8 @@ use std::path::Path;
use bstr::{BStr, ByteSlice};
use gix_glob::pattern::Case;
+use gix_object::FindExt;
-use crate::stack::delegate::FindFn;
use crate::{
stack::state::{Ignore, IgnoreMatchGroup},
PathIdMapping,
@@ -164,7 +164,7 @@ impl Ignore {
rela_dir: &BStr,
buf: &mut Vec<u8>,
id_mappings: &[PathIdMapping],
- find: &mut FindFn<'_>,
+ objects: &dyn gix_object::Find,
case: Case,
stats: &mut Statistics,
) -> std::io::Result<()> {
@@ -177,7 +177,8 @@ impl Ignore {
Source::IdMapping => {
match ignore_file_in_index {
Ok(idx) => {
- let ignore_blob = find(&id_mappings[idx].1, buf)
+ let ignore_blob = objects
+ .find_blob(&id_mappings[idx].1, buf)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
let ignore_path = gix_path::from_bstring(ignore_path_relative.into_owned());
self.stack
@@ -204,7 +205,8 @@ impl Ignore {
if !added {
match ignore_file_in_index {
Ok(idx) => {
- let ignore_blob = find(&id_mappings[idx].1, buf)
+ let ignore_blob = objects
+ .find_blob(&id_mappings[idx].1, buf)
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?;
let ignore_path = gix_path::from_bstring(ignore_path_relative.into_owned());
self.stack