From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix/src/object/commit.rs | 4 ++-- vendor/gix/src/object/mod.rs | 10 +++++++++- vendor/gix/src/object/tag.rs | 11 +++++++++++ vendor/gix/src/object/tree/diff/mod.rs | 9 ++------- vendor/gix/src/object/tree/mod.rs | 17 +++++++++++++++++ 5 files changed, 41 insertions(+), 10 deletions(-) (limited to 'vendor/gix/src/object') diff --git a/vendor/gix/src/object/commit.rs b/vendor/gix/src/object/commit.rs index e28a12955..5a9dfd4f3 100644 --- a/vendor/gix/src/object/commit.rs +++ b/vendor/gix/src/object/commit.rs @@ -109,7 +109,7 @@ impl<'repo> Commit<'repo> { .map(move |id| id.attach(repo)) } - /// Parse the commit and return the the tree object it points to. + /// Parse the commit and return the tree object it points to. pub fn tree(&self) -> Result, Error> { match self.tree_id()?.object()?.try_into_tree() { Ok(tree) => Ok(tree), @@ -117,7 +117,7 @@ impl<'repo> Commit<'repo> { } } - /// Parse the commit and return the the tree id it points to. + /// Parse the commit and return the tree id it points to. pub fn tree_id(&self) -> Result, gix_object::decode::Error> { gix_object::CommitRefIter::from_bytes(&self.data) .tree_id() diff --git a/vendor/gix/src/object/mod.rs b/vendor/gix/src/object/mod.rs index 75d77d138..d0a37db6c 100644 --- a/vendor/gix/src/object/mod.rs +++ b/vendor/gix/src/object/mod.rs @@ -90,6 +90,14 @@ impl<'repo> Object<'repo> { } } + /// Transform this object into a tag, or panic if it is none. + pub fn into_tag(self) -> Tag<'repo> { + match self.try_into() { + Ok(tag) => tag, + Err(this) => panic!("Tried to use {} as commit, but was {}", this.id, this.kind), + } + } + /// Transform this object into a commit, or return it as part of the `Err` if it is no commit. pub fn try_into_commit(self) -> Result, try_into::Error> { self.try_into().map_err(|this: Self| try_into::Error { @@ -157,7 +165,7 @@ impl<'repo> Object<'repo> { }) } - /// Obtain a an iterator over commit tokens like in [`to_commit_iter()`][Object::try_to_commit_ref_iter()]. + /// Obtain an iterator over commit tokens like in [`to_commit_iter()`][Object::try_to_commit_ref_iter()]. /// /// # Panic /// diff --git a/vendor/gix/src/object/tag.rs b/vendor/gix/src/object/tag.rs index ce9d7360a..77eaaa259 100644 --- a/vendor/gix/src/object/tag.rs +++ b/vendor/gix/src/object/tag.rs @@ -1,6 +1,17 @@ use crate::{ext::ObjectIdExt, Tag}; impl<'repo> Tag<'repo> { + /// Decode the entire tag object and return it for accessing all tag information. + /// + /// This never allocates. + /// + /// Note that the returned commit object does make lookup easy and should be + /// used for successive calls to string-ish information to avoid decoding the object + /// more than once. + pub fn decode(&self) -> Result, gix_object::decode::Error> { + gix_object::TagRef::from_bytes(&self.data) + } + /// Decode this tag partially and return the id of its target. pub fn target_id(&self) -> Result, gix_object::decode::Error> { gix_object::TagRefIter::from_bytes(&self.data) 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::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> for gix_object::Tree { + type Error = gix_object::decode::Error; + + fn try_from(t: Tree<'_>) -> Result { + t.decode().map(Into::into) + } + } +} -- cgit v1.2.3