use crate::{Repository, bstr::BStr, revision::Spec};
use gix_error::Exn;
use gix_error::Result;
use gix_hash::ObjectId;
mod types;
pub use types::{ObjectKindHint, Options, RefsHint};
use crate::bstr::BString;
pub mod error;
impl<'repo> Spec<'repo> {
pub fn from_bstr<'a>(spec: impl Into<&'a BStr>, repo: &'repo Repository, opts: Options) -> Result<Self> {
let mut delegate = Delegate::new(repo, opts);
match gix_revision::spec::parse(spec.into(), &mut delegate) {
Err(mut err) => {
if let Some(delegate_err) = delegate.into_delayed_errors() {
let sources: Vec<_> = err.drain_children().collect();
Err(err.chain(delegate_err.chain_all(sources)).into_error())
} else {
Err(err.into_error())
}
}
Ok(()) => delegate.into_rev_spec(),
}
}
}
struct Delegate<'repo> {
refs: [Option<gix_ref::Reference>; 2],
objs: [Option<Vec<ObjectId>>; 2],
paths: [Option<(BString, gix_object::tree::EntryMode)>; 2],
ambiguous_objects: [Option<Vec<ObjectId>>; 2],
idx: usize,
kind: Option<gix_revision::spec::Kind>,
opts: Options,
delayed_errors: Vec<Exn>,
prefix: [Option<gix_hash::Prefix>; 2],
last_call_was_disambiguate_prefix: [bool; 2],
repo: &'repo Repository,
}
mod delegate;