Struct git_repository::revision::Spec
source · pub struct Spec<'repo> { /* private fields */ }
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 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
.