diff options
Diffstat (limited to 'vendor/gix/src/object/tree')
-rw-r--r-- | vendor/gix/src/object/tree/diff/mod.rs | 9 | ||||
-rw-r--r-- | vendor/gix/src/object/tree/mod.rs | 17 |
2 files changed, 19 insertions, 7 deletions
diff --git a/vendor/gix/src/object/tree/diff/mod.rs b/vendor/gix/src/object/tree/diff/mod.rs index 5a3bf6ddf..447eeaa84 100644 --- a/vendor/gix/src/object/tree/diff/mod.rs +++ b/vendor/gix/src/object/tree/diff/mod.rs @@ -3,20 +3,15 @@ use gix_diff::tree::recorder::Location; use crate::{bstr::BStr, Tree}; /// Returned by the `for_each` function to control flow. -#[derive(Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)] +#[derive(Default, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, Hash)] pub enum Action { /// Continue the traversal of changes. + #[default] Continue, /// Stop the traversal of changes and stop calling this function. Cancel, } -impl Default for Action { - fn default() -> Self { - Action::Continue - } -} - /// Represents any possible change in order to turn one tree into another. #[derive(Debug, Clone, Copy)] pub struct Change<'a, 'old, 'new> { diff --git a/vendor/gix/src/object/tree/mod.rs b/vendor/gix/src/object/tree/mod.rs index db094bcb9..bbd392289 100644 --- a/vendor/gix/src/object/tree/mod.rs +++ b/vendor/gix/src/object/tree/mod.rs @@ -22,6 +22,11 @@ impl<'repo> Tree<'repo> { Id::from_id(self.id, self.repo) } + /// Parse our tree data and return the parse tree for direct access to its entries. + pub fn decode(&self) -> Result<gix_object::TreeRef<'_>, gix_object::decode::Error> { + gix_object::TreeRef::from_bytes(&self.data) + } + // TODO: tests. /// Follow a sequence of `path` components starting from this instance, and look them up one by one until the last component /// is looked up and its tree entry is returned. @@ -156,3 +161,15 @@ mod entry { } } } + +mod _impls { + use crate::Tree; + + impl TryFrom<Tree<'_>> for gix_object::Tree { + type Error = gix_object::decode::Error; + + fn try_from(t: Tree<'_>) -> Result<Self, Self::Error> { + t.decode().map(Into::into) + } + } +} |