Skip to content

Commit 58b0e6f

Browse files
committed
feat!: Use stack abstraction in Repository::excludes().
This makes it easier to use.
1 parent c4ffde0 commit 58b0e6f

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

gix/src/repository/attributes.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ impl Repository {
103103
///
104104
/// When only excludes are desired, this is the most efficient way to obtain them. Otherwise use
105105
/// [`Repository::attributes()`] for accessing both attributes and excludes.
106-
// TODO: test, provide higher-level custom Cache wrapper that is much easier to use and doesn't panic when accessing entries
107-
// by non-relative path.
106+
// TODO: test
108107
pub fn excludes(
109108
&self,
110109
index: &gix_index::State,
111110
overrides: Option<gix_ignore::Search>,
112111
source: gix_worktree::stack::state::ignore::Source,
113-
) -> Result<gix_worktree::Stack, config::exclude_stack::Error> {
112+
) -> Result<AttributeStack<'_>, config::exclude_stack::Error> {
114113
let case = if self.config.ignore_case {
115114
gix_glob::pattern::Case::Fold
116115
} else {
@@ -122,13 +121,16 @@ impl Repository {
122121
.assemble_exclude_globals(self.git_dir(), overrides, source, &mut buf)?;
123122
let state = gix_worktree::stack::State::IgnoreStack(ignore);
124123
let attribute_list = state.id_mappings_from_index(index, index.path_backing(), case);
125-
Ok(gix_worktree::Stack::new(
126-
// this is alright as we don't cause mutation of that directory, it's virtual.
127-
self.work_dir().unwrap_or(self.git_dir()),
128-
state,
129-
case,
130-
buf,
131-
attribute_list,
124+
Ok(AttributeStack::new(
125+
gix_worktree::Stack::new(
126+
// this is alright as we don't cause mutation of that directory, it's virtual.
127+
self.work_dir().unwrap_or(self.git_dir()),
128+
state,
129+
case,
130+
buf,
131+
attribute_list,
132+
),
133+
self,
132134
))
133135
}
134136
}

gix/src/worktree/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ pub mod open_index {
112112

113113
///
114114
pub mod excludes {
115+
use crate::AttributeStack;
116+
115117
/// The error returned by [`Worktree::excludes()`][crate::Worktree::excludes()].
116118
#[derive(Debug, thiserror::Error)]
117119
#[allow(missing_docs)]
@@ -132,7 +134,7 @@ pub mod excludes {
132134
///
133135
/// When only excludes are desired, this is the most efficient way to obtain them. Otherwise use
134136
/// [`Worktree::attributes()`][crate::Worktree::attributes()] for accessing both attributes and excludes.
135-
pub fn excludes(&self, overrides: Option<gix_ignore::Search>) -> Result<gix_worktree::Stack, Error> {
137+
pub fn excludes(&self, overrides: Option<gix_ignore::Search>) -> Result<AttributeStack<'_>, Error> {
136138
let index = self.index()?;
137139
Ok(self.parent.excludes(
138140
&index,

0 commit comments

Comments
 (0)