Enum git_repository::head::Kind
source · pub enum Kind {
Symbolic(Reference),
Unborn(FullName),
Detached {
target: ObjectId,
peeled: Option<ObjectId>,
},
}
Expand description
Represents the kind of HEAD
reference.
Variants§
Symbolic(Reference)
The existing reference the symbolic HEAD points to.
This is the common case.
Unborn(FullName)
The yet-to-be-created reference the symbolic HEAD refers to.
This is the case in a newly initialized repository.
Detached
Fields
The head points to an object directly, not to a symbolic reference.
This state is less common and can occur when checking out commits directly.
Implementations§
source§impl Kind
impl Kind
sourcepub fn attach(self, repo: &Repository) -> Head<'_>
pub fn attach(self, repo: &Repository) -> Head<'_>
Attach this instance to a repo
to produce a Head
.
Examples found in repository?
src/repository/reference.rs (line 159)
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
pub fn head(&self) -> Result<crate::Head<'_>, reference::find::existing::Error> {
let head = self.find_reference("HEAD")?;
Ok(match head.inner.target {
Target::Symbolic(branch) => match self.find_reference(&branch) {
Ok(r) => crate::head::Kind::Symbolic(r.detach()),
Err(reference::find::existing::Error::NotFound) => crate::head::Kind::Unborn(branch),
Err(err) => return Err(err),
},
Target::Peeled(target) => crate::head::Kind::Detached {
target,
peeled: head.inner.peeled,
},
}
.attach(self))
}