Skip to main content

Git2Repo

Struct Git2Repo 

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

Concrete git repository backed by libgit2 via the git2 crate.

Construct with Git2Repo::open; then use through the GitRepo trait.

Implementations§

Source§

impl Git2Repo

Source

pub fn open(path: PathBuf) -> Result<Self>

Try to open a git repository by iteratively trying the given path and its parents until a repository root is found.

Trait Implementations§

Source§

impl GitRepo for Git2Repo

Source§

fn head_oid(&self) -> Result<String>

Returns the OID that HEAD currently points at. Read more
Source§

fn find_reference_point(&self, commit_ish: &str) -> Result<String>

Find the merge-base (reference point) between HEAD and a given commit-ish. Read more
Source§

fn list_commits(&self, from_oid: &str, to_oid: &str) -> Result<Vec<CommitInfo>>

List commits from one commit back to another (inclusive). Read more
Source§

fn commit_diff(&self, oid: &str) -> Result<CommitDiff>

Extract the full diff for a single commit compared to its first parent. Read more
Source§

fn commit_diff_for_fragmap(&self, oid: &str) -> Result<CommitDiff>

Extract commit diff with zero context lines, suitable for fragmap analysis. Read more
Source§

fn staged_diff(&self) -> Option<CommitDiff>

Return a synthetic CommitDiff for changes staged in the index (index vs HEAD). Read more
Source§

fn unstaged_diff(&self) -> Option<CommitDiff>

Return a synthetic CommitDiff for unstaged working-tree changes (workdir vs index). Read more
Source§

fn split_commit_per_file(&self, commit_oid: &str, head_oid: &str) -> Result<()>

Split a commit into one commit per changed file. Read more
Source§

fn split_commit_per_hunk(&self, commit_oid: &str, head_oid: &str) -> Result<()>

Split a commit into one commit per hunk. Read more
Source§

fn split_commit_per_hunk_group( &self, commit_oid: &str, head_oid: &str, reference_oid: &str, ) -> Result<()>

Split a commit into one commit per hunk group. Read more
Source§

fn count_split_per_file(&self, commit_oid: &str) -> Result<usize>

Count how many commits split_commit_per_file would produce for this commit.
Source§

fn count_split_per_hunk(&self, commit_oid: &str) -> Result<usize>

Count how many commits split_commit_per_hunk would produce for this commit.
Source§

fn count_split_per_hunk_group( &self, commit_oid: &str, head_oid: &str, reference_oid: &str, ) -> Result<usize>

Count how many fragmap groups split_commit_per_hunk_group would produce for this commit, given the full branch context up to head_oid from reference_oid.
Source§

fn reword_commit( &self, commit_oid: &str, new_message: &str, head_oid: &str, ) -> Result<()>

Reword the message of an existing commit. Read more
Source§

fn get_config_string(&self, key: &str) -> Option<String>

Read a string value from the repository’s git configuration. Read more
Source§

fn drop_commit(&self, commit_oid: &str, head_oid: &str) -> Result<RebaseOutcome>

Drop a commit from the branch by cherry-picking its descendants onto its parent. Read more
Source§

fn rebase_continue(&self, state: &ConflictState) -> Result<RebaseOutcome>

Resume a conflicted rebase after the user has resolved conflicts. Read more
Source§

fn rebase_abort(&self, state: &ConflictState) -> Result<()>

Abort a conflicted rebase and restore the branch to its original state. Read more
Source§

fn workdir(&self) -> Option<PathBuf>

Return the path of the repository’s working directory, if any. Read more
Source§

fn read_index_stage(&self, path: &str, stage: i32) -> Result<Option<Vec<u8>>>

Read the raw blob content of a specific index stage for a conflicted path. Read more
Source§

fn read_conflicting_files(&self) -> Vec<String>

Return the list of paths that currently have conflict markers in the index (entries with stage > 0), sorted alphabetically and deduplicated.
Source§

fn move_commit( &self, commit_oid: &str, insert_after_oid: &str, head_oid: &str, ) -> Result<RebaseOutcome>

Move a commit to a different position on the branch. Read more
Source§

fn squash_commits( &self, source_oid: &str, target_oid: &str, message: &str, head_oid: &str, ) -> Result<RebaseOutcome>

Squash two commits into one. Read more
Source§

fn stage_file(&self, path: &str) -> Result<()>

Stage a working-tree file, clearing any conflict entries for that path. Read more
Source§

fn auto_stage_resolved_conflicts(&self, files: &[String]) -> Result<()>

Auto-stage conflicting files whose working-tree content no longer contains conflict markers. Read more
Source§

fn default_branch(&self) -> Option<String>

Return the name of the repository’s default upstream branch. Read more
Source§

fn squash_try_combine( &self, source_oid: &str, target_oid: &str, combined_message: &str, is_fixup: bool, head_oid: &str, ) -> Result<Option<ConflictState>>

Test whether combining source onto target produces a conflict. Read more
Source§

fn squash_finalize( &self, ctx: &SquashContext, message: &str, original_branch_oid: &str, ) -> Result<RebaseOutcome>

Finalize a squash after the user resolved a squash-time tree conflict. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.