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

Remote

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 find_default_remote() as fallback to handle detached heads, i.e. obtain a remote even in case of detached heads.

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

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.

Peel this instance to make obtaining its final target id possible, while returning an error on unborn heads.

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.

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.

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.

Access

Returns the name of this references, always HEAD.

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

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

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.

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

Try to transform this instance into the symbolic reference that it points to, or return None if head is detached or unborn.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.