Skip to main content

Repository

Struct Repository 

Source
pub struct Repository { /* private fields */ }
Expand description

Wraps a [gix::Repository], representing an open git repository.

Created via Repository::discover, which walks up from path until it finds a .git directory (matching git’s behaviour).

Implementations§

Source§

impl Repository

Source

pub fn discover(path: impl AsRef<Path>) -> Result<Self>

Walk up from path to find the nearest git repository.

Returns an error if no .git directory is found in any ancestor directory.

Source

pub fn workdir(&self) -> Option<&Path>

The absolute path of the repository’s working tree root.

Returns None for bare repositories.

Source

pub fn gitdir(&self) -> &Path

The absolute path of the repository’s .git directory.

Source

pub fn inner(&self) -> &Repository

Access the inner [gix::Repository] for operations that need direct access to the gix API.

Source

pub fn is_bare(&self) -> bool

Check whether this is a bare repository (has no working tree).

Source

pub fn run_git<I, S>(&self, args: I) -> Result<Vec<u8>>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Run a git command in the working directory and return its stdout as bytes. Runs on the calling thread.

Source

pub fn run_git_stdin<I, S>(&self, args: I, input: &[u8]) -> Result<Vec<u8>>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

MG.18a: run a git command with input piped to its stdin, returning stdout as bytes. Runs on the calling thread.

Needed by crate::Index::apply_patch: git apply - reads the patch from stdin, and Self::run_git’s .output() gives the child a null stdin. Writing the patch to a temp file instead would leak it on a crash and race a concurrent magit in the same repository.

The write is completed and stdin dropped before waiting, so a child that consumes its whole input can exit; holding the pipe open past the write deadlocks against a child waiting on EOF.

Source

pub fn run_git_str<I, S>(&self, args: I) -> Result<String>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Run a git command and return stdout as a UTF-8 string.

Source

pub fn run_git_lines<I, S>(&self, args: I) -> Result<Vec<String>>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Run a git command and return stdout lines as trimmed UTF-8 strings.

Trait Implementations§

Source§

impl Debug for Repository

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.