pub enum HeadState {
Branch {
refname: String,
short_name: String,
oid: Option<ObjectId>,
},
Detached {
oid: ObjectId,
},
Invalid,
}Expand description
The current state of HEAD.
Variants§
Branch
HEAD points to a branch via a symbolic ref (e.g. ref: refs/heads/main).
Fields
Detached
HEAD is detached — pointing directly at a commit.
Invalid
HEAD is in an invalid or unreadable state.
Implementations§
Source§impl HeadState
impl HeadState
Sourcepub fn branch_name(&self) -> Option<&str>
pub fn branch_name(&self) -> Option<&str>
Return the branch name if HEAD is on a branch.
Sourcepub fn is_detached(&self) -> bool
pub fn is_detached(&self) -> bool
Whether HEAD is detached.
Sourcepub fn tree(&self, odb: &Odb) -> Result<Option<ObjectId>>
pub fn tree(&self, odb: &Odb) -> Result<Option<ObjectId>>
The root tree of the commit this state names.
Use this when an unreadable HEAD should be treated like an unborn branch (for example
to diff the index against “nothing”); use Repository::head_tree when it must be an
error.
§Parameters
odb: the object database holding the commit.
§Returns
Some(tree) when Self::oid names a commit, None on an unborn branch or an
HeadState::Invalid HEAD.
§Errors
Same as Odb::commit_tree: the commit is missing, is not
a commit, or has no valid tree header.
Trait Implementations§
impl Eq for HeadState
impl StructuralPartialEq for HeadState
Auto Trait Implementations§
impl Freeze for HeadState
impl RefUnwindSafe for HeadState
impl Send for HeadState
impl Sync for HeadState
impl Unpin for HeadState
impl UnsafeUnpin for HeadState
impl UnwindSafe for HeadState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.