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§
source§impl<'repo> Head<'repo>
impl<'repo> Head<'repo>
Remote
sourcepub fn into_remote(
self,
direction: Direction
) -> Option<Result<Remote<'repo>, Error>>
pub fn into_remote( self, direction: Direction ) -> Option<Result<Remote<'repo>, Error>>
Return the remote with which the currently checked our reference can be handled as configured by branch.<name>.remote|pushRemote
or fall back to the non-branch specific remote configuration. None
is returned if the head is detached or unborn, so there is
no branch specific remote.
This is equivalent to calling Reference::remote(…)
and
Repository::remote_default_name()
in order.
Combine it with Repository::find_default_remote()
as fallback to
handle detached heads, i.e. obtain a remote even in case of detached heads,
or call Repository::find_fetch_remote(…)
for the highest-level way of finding
the right remote, just like git fetch
does.
source§impl<'repo> Head<'repo>
impl<'repo> Head<'repo>
sourcepub fn log_iter(&self) -> Platform<'static, 'repo>
pub fn log_iter(&self) -> Platform<'static, 'repo>
Return a platform for obtaining iterators on the reference log associated with the HEAD
reference.
sourcepub fn prior_checked_out_branches(
&self
) -> Result<Option<Vec<(BString, ObjectId)>>>
pub fn prior_checked_out_branches( &self ) -> Result<Option<Vec<(BString, ObjectId)>>>
Return a list of all branch names that were previously checked out with the first-ever checked out branch being the first entry of the list, and the most recent is the last, along with the commit they were pointing to at the time.
source§impl<'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.
source§impl<'repo> Head<'repo>
impl<'repo> Head<'repo>
Access
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 is_unborn(&self) -> bool
pub fn is_unborn(&self) -> bool
Returns true if this instance is not yet born, hence it points to a ref that doesn’t exist yet.
This is the case in a newly initialized repository.
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 try_into_referent(self) -> Option<Reference<'repo>>
pub fn try_into_referent(self) -> Option<Reference<'repo>>
Try to transform this instance into the symbolic reference that it points to, or return None
if head is detached or unborn.