diff options
Diffstat (limited to 'vendor/gix/src/id.rs')
-rw-r--r-- | vendor/gix/src/id.rs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/vendor/gix/src/id.rs b/vendor/gix/src/id.rs index 0d5c86752..7214ec320 100644 --- a/vendor/gix/src/id.rs +++ b/vendor/gix/src/id.rs @@ -3,9 +3,9 @@ use std::ops::Deref; use gix_hash::{oid, ObjectId}; -use crate::{object::find, revision, Id, Object}; +use crate::{object::find, Id, Object}; -/// An [object id][ObjectId] infused with `Easy`. +/// An [object id][ObjectId] infused with a [`Repository`][crate::Repository]. impl<'repo> Id<'repo> { /// Find the [`Object`] associated with this object id, and consider it an error if it doesn't exist. /// @@ -16,6 +16,13 @@ impl<'repo> Id<'repo> { self.repo.find_object(self.inner) } + /// Find the [`header`][gix_odb::find::Header] associated with this object id, or an error if it doesn't exist. + /// + /// Use this method if there is no interest in the contents of the object, which generally is much faster to obtain. + pub fn header(&self) -> Result<gix_odb::find::Header, find::existing::Error> { + self.repo.find_header(self.inner) + } + /// Try to find the [`Object`] associated with this object id, and return `None` if it's not available locally. /// /// # Note @@ -25,6 +32,13 @@ impl<'repo> Id<'repo> { self.repo.try_find_object(self.inner) } + /// Find the [`header`][gix_odb::find::Header] associated with this object id, or return `None` if it doesn't exist. + /// + /// Use this method if there is no interest in the contents of the object, which generally is much faster to obtain. + pub fn try_header(&self) -> Result<Option<gix_odb::find::Header>, find::Error> { + self.repo.try_find_header(self.inner) + } + /// Turn this object id into a shortened id with a length in hex as configured by `core.abbrev`. pub fn shorten(&self) -> Result<gix_hash::Prefix, shorten::Error> { let hex_len = self.repo.config.hex_len.map_or_else( @@ -89,9 +103,8 @@ impl<'repo> Id<'repo> { impl<'repo> Id<'repo> { /// Obtain a platform for traversing ancestors of this commit. - /// - pub fn ancestors(&self) -> revision::walk::Platform<'repo> { - revision::walk::Platform::new(Some(self.inner), self.repo) + pub fn ancestors(&self) -> crate::revision::walk::Platform<'repo> { + crate::revision::walk::Platform::new(Some(self.inner), self.repo) } } |