pub struct Branch { /* private fields */ }Expand description
Represents a Git branch.
A branch is a named reference that points to a commit.
The branch name does not include the refs/heads/ prefix.
Implementations§
Source§impl Branch
impl Branch
Sourcepub fn new(name: impl Into<String>, oid: Oid) -> Self
pub fn new(name: impl Into<String>, oid: Oid) -> Self
Creates a new Branch.
§Arguments
name- The branch name (withoutrefs/heads/prefix).oid- The commit OID the branch points to.
Sourcepub fn current(name: impl Into<String>, oid: Oid) -> Self
pub fn current(name: impl Into<String>, oid: Oid) -> Self
Creates a new Branch marked as current.
§Arguments
name- The branch name (withoutrefs/heads/prefix).oid- The commit OID the branch points to.
Sourcepub fn is_current(&self) -> bool
pub fn is_current(&self) -> bool
Returns true if this is the current branch.
Sourcepub fn reference_name(&self) -> String
pub fn reference_name(&self) -> String
Returns the full reference name (with refs/heads/ prefix).
Sourcepub fn short_oid(&self) -> String
pub fn short_oid(&self) -> String
Returns a short representation of the commit OID (7 characters).
Sourcepub fn set_current(&mut self, is_current: bool)
pub fn set_current(&mut self, is_current: bool)
Sets whether this branch is the current branch.
Trait Implementations§
impl Eq for Branch
impl StructuralPartialEq for Branch
Auto Trait Implementations§
impl Freeze for Branch
impl RefUnwindSafe for Branch
impl Send for Branch
impl Sync for Branch
impl Unpin for Branch
impl UnwindSafe for Branch
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