Struct gix::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§

source§

impl<'repo> Head<'repo>

Remote

source

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>

source

pub fn log_iter(&self) -> Platform<'static, 'repo>

Return a platform for obtaining iterators on the reference log associated with the HEAD reference.

source

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>

source

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.

source

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.

source

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

pub fn into_fully_peeled_id(self) -> Option<Result<Id<'repo>, Error>>

Consume this instance and transform it into the final object that it points to, or None if the HEAD reference is yet to be born.

source§

impl<'repo> Head<'repo>

Access

source

pub fn name(&self) -> &'static FullNameRef

Returns the name of this references, always HEAD.

source

pub fn referent_name(&self) -> Option<&FullNameRef>

Returns the full reference name of this head if it is not detached, or None otherwise.

source

pub fn is_detached(&self) -> bool

Returns true if this instance is detached, and points to an object directly.

source

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.

source

pub fn id(&self) -> Option<Id<'repo>>

Returns the id the head points to, which isn’t possible on unborn heads.

source

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.

Trait Implementations§

source§

impl<'repo> Clone for Head<'repo>

source§

fn clone(&self) -> Head<'repo>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.