summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/repository/revision.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
commit10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch)
treebdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/gix/src/repository/revision.rs
parentReleasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff)
downloadrustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz
rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/repository/revision.rs')
-rw-r--r--vendor/gix/src/repository/revision.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/gix/src/repository/revision.rs b/vendor/gix/src/repository/revision.rs
new file mode 100644
index 000000000..3018c2be8
--- /dev/null
+++ b/vendor/gix/src/repository/revision.rs
@@ -0,0 +1,42 @@
+use crate::{bstr::BStr, revision, Id};
+
+/// Methods for resolving revisions by spec or working with the commit graph.
+impl crate::Repository {
+ /// Parse a revision specification and turn it into the object(s) it describes, similar to `git rev-parse`.
+ ///
+ /// # Deviation
+ ///
+ /// - `@` actually stands for `HEAD`, whereas `git` resolves it to the object pointed to by `HEAD` without making the
+ /// `HEAD` ref available for lookups.
+ pub fn rev_parse<'a>(&self, spec: impl Into<&'a BStr>) -> Result<revision::Spec<'_>, revision::spec::parse::Error> {
+ revision::Spec::from_bstr(
+ spec,
+ self,
+ revision::spec::parse::Options {
+ object_kind_hint: self.config.object_kind_hint,
+ ..Default::default()
+ },
+ )
+ }
+
+ /// Parse a revision specification and return single object id as represented by this instance.
+ pub fn rev_parse_single<'repo, 'a>(
+ &'repo self,
+ spec: impl Into<&'a BStr>,
+ ) -> Result<Id<'repo>, revision::spec::parse::single::Error> {
+ let spec = spec.into();
+ self.rev_parse(spec)?
+ .single()
+ .ok_or(revision::spec::parse::single::Error::RangedRev { spec: spec.into() })
+ }
+
+ /// Create the baseline for a revision walk by initializing it with the `tips` to start iterating on.
+ ///
+ /// It can be configured further before starting the actual walk.
+ pub fn rev_walk(
+ &self,
+ tips: impl IntoIterator<Item = impl Into<gix_hash::ObjectId>>,
+ ) -> revision::walk::Platform<'_> {
+ revision::walk::Platform::new(tips, self)
+ }
+}