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
impl Repository
Sourcepub fn discover(path: impl AsRef<Path>) -> Result<Self>
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.
Sourcepub fn workdir(&self) -> Option<&Path>
pub fn workdir(&self) -> Option<&Path>
The absolute path of the repository’s working tree root.
Returns None for bare repositories.
Sourcepub fn inner(&self) -> &Repository
pub fn inner(&self) -> &Repository
Access the inner [gix::Repository] for operations that need
direct access to the gix API.
Sourcepub fn run_git<I, S>(&self, args: I) -> Result<Vec<u8>>
pub fn run_git<I, S>(&self, args: I) -> Result<Vec<u8>>
Run a git command in the working directory and return its stdout as bytes. Runs on the calling thread.
Sourcepub fn run_git_stdin<I, S>(&self, args: I, input: &[u8]) -> Result<Vec<u8>>
pub fn run_git_stdin<I, S>(&self, args: I, input: &[u8]) -> Result<Vec<u8>>
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.
Sourcepub fn run_git_str<I, S>(&self, args: I) -> Result<String>
pub fn run_git_str<I, S>(&self, args: I) -> Result<String>
Run a git command and return stdout as a UTF-8 string.
Sourcepub fn run_git_lines<I, S>(&self, args: I) -> Result<Vec<String>>
pub fn run_git_lines<I, S>(&self, args: I) -> Result<Vec<String>>
Run a git command and return stdout lines as trimmed UTF-8 strings.