Struct git2::Branch

source ·
pub struct Branch<'repo> { /* private fields */ }
Expand description

A structure to represent a git branch

A branch is currently just a wrapper to an underlying Reference. The reference can be accessed through the get and into_reference methods.

Implementations§

source§

impl<'repo> Branch<'repo>

source

pub fn wrap(reference: Reference<'_>) -> Branch<'_>

Creates Branch type from a Reference

source

pub fn name_is_valid(name: &str) -> Result<bool, Error>

Ensure the branch name is well-formed.

source

pub fn get(&self) -> &Reference<'repo>

Gain access to the reference that is this branch

source

pub fn get_mut(&mut self) -> &mut Reference<'repo>

Gain mutable access to the reference that is this branch

source

pub fn into_reference(self) -> Reference<'repo>

Take ownership of the underlying reference.

source

pub fn delete(&mut self) -> Result<(), Error>

Delete an existing branch reference.

source

pub fn is_head(&self) -> bool

Determine if the current local branch is pointed at by HEAD.

source

pub fn rename( &mut self, new_branch_name: &str, force: bool ) -> Result<Branch<'repo>, Error>

Move/rename an existing local branch reference.

source

pub fn name(&self) -> Result<Option<&str>, Error>

Return the name of the given local or remote branch.

May return Ok(None) if the name is not valid utf-8.

source

pub fn name_bytes(&self) -> Result<&[u8], Error>

Return the name of the given local or remote branch.

source

pub fn upstream(&self) -> Result<Branch<'repo>, Error>

Return the reference supporting the remote tracking branch, given a local branch reference.

source

pub fn set_upstream(&mut self, upstream_name: Option<&str>) -> Result<(), Error>

Set the upstream configuration for a given local branch.

If None is specified, then the upstream branch is unset. The name provided is the name of the branch to set as upstream.

Auto Trait Implementations§

§

impl<'repo> RefUnwindSafe for Branch<'repo>

§

impl<'repo> !Send for Branch<'repo>

§

impl<'repo> !Sync for Branch<'repo>

§

impl<'repo> Unpin for Branch<'repo>

§

impl<'repo> UnwindSafe for Branch<'repo>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.