Skip to content

Commit 5f86e6b

Browse files
committed
adapt to changes in gix-index
1 parent 2ea87f0 commit 5f86e6b

File tree

6 files changed

+42
-15
lines changed

6 files changed

+42
-15
lines changed

gix-fs/tests/stack/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::join_absolute_paths)]
12
use std::path::{Path, PathBuf};
23

34
use gix_fs::Stack;

gix/src/clone/checkout.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ pub mod main_worktree {
1818
#[error("Could not create index from tree at {id}")]
1919
IndexFromTree {
2020
id: gix_hash::ObjectId,
21-
source: gix_traverse::tree::breadthfirst::Error,
21+
source: gix_index::init::from_tree::Error,
2222
},
23+
#[error("Couldn't obtain configuration for core.protect*")]
24+
BooleanConfig(#[from] crate::config::boolean::Error),
2325
#[error(transparent)]
2426
WriteIndex(#[from] gix_index::file::write::Error),
2527
#[error(transparent)]
@@ -95,10 +97,11 @@ pub mod main_worktree {
9597
))
9698
}
9799
};
98-
let index = gix_index::State::from_tree(&root_tree, &repo.objects).map_err(|err| Error::IndexFromTree {
99-
id: root_tree,
100-
source: err,
101-
})?;
100+
let index = gix_index::State::from_tree(&root_tree, &repo.objects, repo.config.protect_options()?)
101+
.map_err(|err| Error::IndexFromTree {
102+
id: root_tree,
103+
source: err,
104+
})?;
102105
let mut index = gix_index::File::from_state(index, repo.index_path());
103106

104107
let mut opts = repo

gix/src/config/cache/access.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ impl Cache {
271271
})
272272
}
273273

274-
#[cfg(feature = "worktree-mutation")]
275-
fn protect_options(&self) -> Result<gix_validate::path::component::Options, config::boolean::Error> {
274+
#[cfg(feature = "index")]
275+
pub(crate) fn protect_options(&self) -> Result<gix_validate::path::component::Options, config::boolean::Error> {
276276
const IS_WINDOWS: bool = cfg!(windows);
277277
const IS_MACOS: bool = cfg!(target_os = "macos");
278278
const ALWAYS_ON_FOR_SAFETY: bool = true;

gix/src/repository/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod pipeline {
1212
#[error(transparent)]
1313
DecodeCommit(#[from] gix_object::decode::Error),
1414
#[error("Could not create index from tree at HEAD^{{tree}}")]
15-
TreeTraverse(#[from] gix_traverse::tree::breadthfirst::Error),
15+
TreeTraverse(#[from] crate::repository::index_from_tree::Error),
1616
#[error(transparent)]
1717
BareAttributes(#[from] crate::config::attribute_stack::Error),
1818
#[error(transparent)]

gix/src/repository/index.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ impl crate::Repository {
111111
/// Create new index-file, which would live at the correct location, in memory from the given `tree`.
112112
///
113113
/// Note that this is an expensive operation as it requires recursively traversing the entire tree to unpack it into the index.
114-
pub fn index_from_tree(
115-
&self,
116-
tree: &gix_hash::oid,
117-
) -> Result<gix_index::File, gix_traverse::tree::breadthfirst::Error> {
114+
pub fn index_from_tree(&self, tree: &gix_hash::oid) -> Result<gix_index::File, super::index_from_tree::Error> {
118115
Ok(gix_index::File::from_state(
119-
gix_index::State::from_tree(tree, &self.objects)?,
116+
gix_index::State::from_tree(tree, &self.objects, self.config.protect_options()?).map_err(|err| {
117+
super::index_from_tree::Error::IndexFromTree {
118+
id: tree.into(),
119+
source: err,
120+
}
121+
})?,
120122
self.git_dir().join("index"),
121123
))
122124
}

gix/src/repository/mod.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ pub mod attributes;
4141
mod cache;
4242
mod config;
4343
///
44+
#[allow(clippy::empty_docs)]
4445
#[cfg(feature = "blob-diff")]
4546
pub mod diff;
4647
///
48+
#[allow(clippy::empty_docs)]
4749
#[cfg(feature = "dirwalk")]
4850
mod dirwalk;
4951
///
52+
#[allow(clippy::empty_docs)]
5053
#[cfg(feature = "attributes")]
5154
pub mod filter;
5255
mod graph;
@@ -73,6 +76,24 @@ mod submodule;
7376
mod thread_safe;
7477
mod worktree;
7578

79+
///
80+
#[allow(clippy::empty_docs)]
81+
#[cfg(feature = "index")]
82+
pub mod index_from_tree {
83+
/// The error returned by [Repository::index_from_tree()](crate::Repository::index_from_tree).
84+
#[derive(Debug, thiserror::Error)]
85+
#[allow(missing_docs)]
86+
pub enum Error {
87+
#[error("Could not create index from tree at {id}")]
88+
IndexFromTree {
89+
id: gix_hash::ObjectId,
90+
source: gix_index::init::from_tree::Error,
91+
},
92+
#[error("Couldn't obtain configuration for core.protect*")]
93+
BooleanConfig(#[from] crate::config::boolean::Error),
94+
}
95+
}
96+
7697
///
7798
#[allow(clippy::empty_docs)]
7899
pub mod branch_remote_ref_name {
@@ -133,7 +154,7 @@ pub mod index_or_load_from_head {
133154
#[error(transparent)]
134155
TreeId(#[from] gix_object::decode::Error),
135156
#[error(transparent)]
136-
TraverseTree(#[from] gix_traverse::tree::breadthfirst::Error),
157+
TraverseTree(#[from] crate::repository::index_from_tree::Error),
137158
#[error(transparent)]
138159
OpenIndex(#[from] crate::worktree::open_index::Error),
139160
}
@@ -149,7 +170,7 @@ pub mod worktree_stream {
149170
#[error(transparent)]
150171
FindTree(#[from] crate::object::find::existing::Error),
151172
#[error(transparent)]
152-
OpenTree(#[from] gix_traverse::tree::breadthfirst::Error),
173+
OpenTree(#[from] crate::repository::index_from_tree::Error),
153174
#[error(transparent)]
154175
AttributesCache(#[from] crate::config::attribute_stack::Error),
155176
#[error(transparent)]

0 commit comments

Comments
 (0)