summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/revision/spec/parse
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix/src/revision/spec/parse')
-rw-r--r--vendor/gix/src/revision/spec/parse/delegate/mod.rs7
-rw-r--r--vendor/gix/src/revision/spec/parse/delegate/navigate.rs24
-rw-r--r--vendor/gix/src/revision/spec/parse/delegate/revision.rs8
-rw-r--r--vendor/gix/src/revision/spec/parse/mod.rs2
-rw-r--r--vendor/gix/src/revision/spec/parse/types.rs10
5 files changed, 25 insertions, 26 deletions
diff --git a/vendor/gix/src/revision/spec/parse/delegate/mod.rs b/vendor/gix/src/revision/spec/parse/delegate/mod.rs
index 78e4ab9ee..eaf7f5fd6 100644
--- a/vendor/gix/src/revision/spec/parse/delegate/mod.rs
+++ b/vendor/gix/src/revision/spec/parse/delegate/mod.rs
@@ -1,10 +1,7 @@
use std::collections::HashSet;
use gix_hash::ObjectId;
-use gix_revision::spec::{
- parse,
- parse::delegate::{self},
-};
+use gix_revision::spec::{parse, parse::delegate};
use smallvec::SmallVec;
use super::{Delegate, Error, ObjectKindHint};
@@ -209,7 +206,7 @@ impl<'repo> Delegate<'repo> {
.attach(repo)
.peel_to_id_in_place()
.ok()
- .map(|id| id.detach())
+ .map(crate::Id::detach)
}) {
obj_opt.get_or_insert_with(HashSet::default).insert(id);
};
diff --git a/vendor/gix/src/revision/spec/parse/delegate/navigate.rs b/vendor/gix/src/revision/spec/parse/delegate/navigate.rs
index f6e085368..51feb1d76 100644
--- a/vendor/gix/src/revision/spec/parse/delegate/navigate.rs
+++ b/vendor/gix/src/revision/spec/parse/delegate/navigate.rs
@@ -15,6 +15,7 @@ use crate::{
delegate::{handle_errors_and_replacements, peel, Replacements},
Delegate, Error,
},
+ Object,
};
impl<'repo> delegate::Navigate for Delegate<'repo> {
@@ -62,10 +63,9 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
.all()
.expect("cannot fail without sorting")
.skip(num)
- .filter_map(Result::ok)
- .next()
+ .find_map(Result::ok)
{
- Some(id) => replacements.push((*obj, id.detach())),
+ Some(commit) => replacements.push((*obj, commit.id)),
None => errors.push((
*obj,
Error::AncestorOutOfRange {
@@ -123,9 +123,9 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
if path.is_empty() {
return Ok(tree_id);
}
- let tree = repo.find_object(tree_id)?.into_tree();
+ let mut tree = repo.find_object(tree_id)?.into_tree();
let entry =
- tree.lookup_entry_by_path(gix_path::from_bstr(path))?
+ tree.peel_to_entry_by_path(gix_path::from_bstr(path))?
.ok_or_else(|| Error::PathNotFound {
path: path.into(),
object: obj.attach(repo).shorten_or_id(),
@@ -142,7 +142,7 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
}
PeelTo::RecursiveTagObject => {
for oid in objs.iter() {
- match oid.attach(repo).object().and_then(|obj| obj.peel_tags_to_end()) {
+ match oid.attach(repo).object().and_then(Object::peel_tags_to_end) {
Ok(obj) => replacements.push((*oid, obj.id)),
Err(err) => errors.push((*oid, err.into())),
}
@@ -157,9 +157,9 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
self.unset_disambiguate_call();
self.follow_refs_to_objects_if_needed()?;
- #[cfg(not(feature = "regex"))]
+ #[cfg(not(feature = "revparse-regex"))]
let matches = |message: &BStr| -> bool { message.contains_str(regex) ^ negated };
- #[cfg(feature = "regex")]
+ #[cfg(feature = "revparse-regex")]
let matches = match regex::bytes::Regex::new(regex.to_str_lossy().as_ref()) {
Ok(compiled) => {
let needs_regex = regex::escape(compiled.as_str()) != regex;
@@ -193,8 +193,8 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
let mut matched = false;
let mut count = 0;
let commits = iter.map(|res| {
- res.map_err(Error::from).and_then(|commit_id| {
- commit_id.object().map_err(Error::from).map(|obj| obj.into_commit())
+ res.map_err(Error::from).and_then(|commit| {
+ commit.id().object().map_err(Error::from).map(Object::into_commit)
})
});
for commit in commits {
@@ -250,8 +250,8 @@ impl<'repo> delegate::Navigate for Delegate<'repo> {
let mut matched = false;
let mut count = 0;
let commits = iter.map(|res| {
- res.map_err(Error::from).and_then(|commit_id| {
- commit_id.object().map_err(Error::from).map(|obj| obj.into_commit())
+ res.map_err(Error::from).and_then(|commit| {
+ commit.id().object().map_err(Error::from).map(Object::into_commit)
})
});
for commit in commits {
diff --git a/vendor/gix/src/revision/spec/parse/delegate/revision.rs b/vendor/gix/src/revision/spec/parse/delegate/revision.rs
index 7ea691a28..2b84dda23 100644
--- a/vendor/gix/src/revision/spec/parse/delegate/revision.rs
+++ b/vendor/gix/src/revision/spec/parse/delegate/revision.rs
@@ -114,7 +114,7 @@ impl<'repo> delegate::Revision for Delegate<'repo> {
ReflogLookup::Entry(no) => {
let r = match &mut self.refs[self.idx] {
Some(r) => r.clone().attach(self.repo),
- val @ None => match self.repo.head().map(|head| head.try_into_referent()) {
+ val @ None => match self.repo.head().map(crate::Head::try_into_referent) {
Ok(Some(r)) => {
*val = Some(r.clone().detach());
r
@@ -139,7 +139,7 @@ impl<'repo> delegate::Revision for Delegate<'repo> {
Some(())
}
None => {
- let available = platform.rev().ok().flatten().map_or(0, |it| it.count());
+ let available = platform.rev().ok().flatten().map_or(0, Iterator::count);
self.err.push(Error::RefLogEntryOutOfRange {
reference: r.detach(),
desired: no,
@@ -190,7 +190,7 @@ impl<'repo> delegate::Revision for Delegate<'repo> {
Ok(Some((ref_name, id))) => {
let id = match self.repo.find_reference(ref_name.as_bstr()) {
Ok(mut r) => {
- let id = r.peel_to_id_in_place().map(|id| id.detach()).unwrap_or(id);
+ let id = r.peel_to_id_in_place().map(crate::Id::detach).unwrap_or(id);
self.refs[self.idx] = Some(r.detach());
id
}
@@ -203,7 +203,7 @@ impl<'repo> delegate::Revision for Delegate<'repo> {
self.err.push(Error::PriorCheckoutOutOfRange {
desired: branch_no,
available: prior_checkouts_iter(&mut head.log_iter())
- .map(|it| it.count())
+ .map(Iterator::count)
.unwrap_or(0),
});
None
diff --git a/vendor/gix/src/revision/spec/parse/mod.rs b/vendor/gix/src/revision/spec/parse/mod.rs
index f69ecc4af..950dfa004 100644
--- a/vendor/gix/src/revision/spec/parse/mod.rs
+++ b/vendor/gix/src/revision/spec/parse/mod.rs
@@ -1,6 +1,7 @@
use std::collections::HashSet;
use gix_hash::ObjectId;
+use gix_macros::momo;
use gix_revision::spec::parse;
use crate::{bstr::BStr, revision::Spec, Repository};
@@ -30,6 +31,7 @@ impl<'repo> Spec<'repo> {
/// Parse `spec` and use information from `repo` to resolve it, using `opts` to learn how to deal with ambiguity.
///
/// Note that it's easier and to use [`repo.rev_parse()`][Repository::rev_parse()] instead.
+ #[momo]
pub fn from_bstr<'a>(spec: impl Into<&'a BStr>, repo: &'repo Repository, opts: Options) -> Result<Self, Error> {
let mut delegate = Delegate::new(repo, opts);
match gix_revision::spec::parse(spec.into(), &mut delegate) {
diff --git a/vendor/gix/src/revision/spec/parse/types.rs b/vendor/gix/src/revision/spec/parse/types.rs
index d852c297e..5dc626eee 100644
--- a/vendor/gix/src/revision/spec/parse/types.rs
+++ b/vendor/gix/src/revision/spec/parse/types.rs
@@ -100,15 +100,15 @@ pub enum Error {
RevWalkIterInit(#[from] crate::reference::iter::init::Error),
#[error(transparent)]
RevWalkAllReferences(#[from] gix_ref::packed::buffer::open::Error),
- #[cfg(feature = "regex")]
+ #[cfg(feature = "revparse-regex")]
#[error(transparent)]
InvalidRegex(#[from] regex::Error),
#[cfg_attr(
- feature = "regex",
+ feature = "revparse-regex",
error("None of {commits_searched} commits from {oid} matched regex {regex:?}")
)]
#[cfg_attr(
- not(feature = "regex"),
+ not(feature = "revparse-regex"),
error("None of {commits_searched} commits from {oid} matched text {regex:?}")
)]
NoRegexMatch {
@@ -117,11 +117,11 @@ pub enum Error {
commits_searched: usize,
},
#[cfg_attr(
- feature = "regex",
+ feature = "revparse-regex",
error("None of {commits_searched} commits reached from all references matched regex {regex:?}")
)]
#[cfg_attr(
- not(feature = "regex"),
+ not(feature = "revparse-regex"),
error("None of {commits_searched} commits reached from all references matched text {regex:?}")
)]
NoRegexMatchAllRefs { regex: BString, commits_searched: usize },