Struct git_repository::Head
source · [−]pub struct Head<'repo> {
pub kind: Kind,
/* private fields */
}
Expand description
The head reference, as created from looking at .git/HEAD
, able to represent all of its possible states.
Note that like Reference
, this type’s data is snapshot of persisted state on disk.
Fields
kind: Kind
One of various possible states for the HEAD reference
Implementations
sourceimpl<'repo> Head<'repo>
impl<'repo> Head<'repo>
sourcepub fn peeled(self) -> Result<Self, Error>
pub fn peeled(self) -> Result<Self, Error>
Peel this instance to make obtaining its final target id possible, while returning an error on unborn heads.
sourcepub fn peel_to_id_in_place(&mut self) -> Option<Result<Id<'repo>, Error>>
pub fn peel_to_id_in_place(&mut self) -> Option<Result<Id<'repo>, Error>>
Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no more object to follow, and return that object id.
Returns None
if the head is unborn.
sourcepub fn peel_to_commit_in_place(&mut self) -> Result<Commit<'repo>, Error>
pub fn peel_to_commit_in_place(&mut self) -> Result<Commit<'repo>, Error>
Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no more object to follow, transform the id into a commit if possible and return that.
Returns an error if the head is unborn or if it doesn’t point to a commit.
sourceimpl<'repo> Head<'repo>
impl<'repo> Head<'repo>
sourcepub fn name(&self) -> &'static FullNameRef
pub fn name(&self) -> &'static FullNameRef
Returns the name of this references, always HEAD
.
sourcepub fn referent_name(&self) -> Option<&FullNameRef>
pub fn referent_name(&self) -> Option<&FullNameRef>
Returns the full reference name of this head if it is not detached, or None
otherwise.
sourcepub fn is_detached(&self) -> bool
pub fn is_detached(&self) -> bool
Returns true if this instance is detached, and points to an object directly.
sourcepub fn id(&self) -> Option<Id<'repo>>
pub fn id(&self) -> Option<Id<'repo>>
Returns the id the head points to, which isn’t possible on unborn heads.
sourcepub fn into_referent(self) -> Reference<'repo>
pub fn into_referent(self) -> Reference<'repo>
Force transforming this instance into the symbolic reference that it points to, or panic if it is unborn or detached.
Panics
If this isn’t actually a head pointing to a symbolic reference.
Auto Trait Implementations
impl<'repo> !RefUnwindSafe for Head<'repo>
impl<'repo> !Send for Head<'repo>
impl<'repo> !Sync for Head<'repo>
impl<'repo> Unpin for Head<'repo>
impl<'repo> !UnwindSafe for Head<'repo>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more