pub struct Spec<'repo> { /* private fields */ }
revision
only.Expand description
The specification of a revision as parsed from a revision specification like HEAD@{1}
or v1.2.3...main
.
It’s typically created by repo.rev_parse()
.
See the official git documentation for reference on how to specify revisions and revision ranges.
Implementations§
source§impl<'repo> Spec<'repo>
impl<'repo> Spec<'repo>
sourcepub fn from_bstr<'a>(
spec: impl Into<&'a BStr>,
repo: &'repo Repository,
opts: Options,
) -> Result<Self, Error>
pub fn from_bstr<'a>( spec: impl Into<&'a BStr>, repo: &'repo Repository, opts: Options, ) -> Result<Self, Error>
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()
instead.
source§impl<'repo> Spec<'repo>
impl<'repo> Spec<'repo>
Access
sourcepub fn detach(self) -> Spec
pub fn detach(self) -> Spec
Detach the Repository
from this instance, leaving only plain data that can be moved freely and serialized.
sourcepub fn into_references(
self,
) -> (Option<Reference<'repo>>, Option<Reference<'repo>>)
pub fn into_references( self, ) -> (Option<Reference<'repo>>, Option<Reference<'repo>>)
Some revision specifications leave information about references which are returned as (from-ref, to-ref)
here, e.g.
HEAD@{-1}..main
might be (Some(refs/heads/previous-branch), Some(refs/heads/main))
,
or @
returns (Some(refs/heads/main), None)
.
sourcepub fn path_and_mode(&self) -> Option<(&BStr, EntryMode)>
pub fn path_and_mode(&self) -> Option<(&BStr, EntryMode)>
Return the path encountered in specs like @:<path>
or :<path>
, along with the kind of object it represents.
Note that there can only be one as paths always terminates further revspec parsing.
sourcepub fn first_reference(&self) -> Option<&Reference>
pub fn first_reference(&self) -> Option<&Reference>
Return the name of the first reference we encountered while resolving the rev-spec, or None
if a short hash
was used. For example, @
might yield Some(HEAD)
, but abcd
yields None
.
sourcepub fn second_reference(&self) -> Option<&Reference>
pub fn second_reference(&self) -> Option<&Reference>
Return the name of the second reference we encountered while resolving the rev-spec, or None
if a short hash
was used or there was no second reference. For example, ..@
might yield Some(HEAD)
, but ..abcd
or @
yields None
.
Methods from Deref<Target = Spec>§
Trait Implementations§
impl<'repo> Eq for Spec<'repo>
Auto Trait Implementations§
impl<'repo> Freeze for Spec<'repo>
impl<'repo> !RefUnwindSafe for Spec<'repo>
impl<'repo> !Send for Spec<'repo>
impl<'repo> !Sync for Spec<'repo>
impl<'repo> Unpin for Spec<'repo>
impl<'repo> !UnwindSafe for Spec<'repo>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)