pub struct Git { /* private fields */ }Expand description
git 调用上下文:锚定仓库根目录,verbose 时回显执行的命令。
Implementations§
Source§impl Git
impl Git
Sourcepub fn run_inherit(&self, args: &[&str]) -> Result<ExitStatus, GitError>
pub fn run_inherit(&self, args: &[&str]) -> Result<ExitStatus, GitError>
以透传模式执行 git:输出直接接到用户终端, 用于发起 merge / rebase / pull(保留 git 自身的进度显示)。
Sourcepub fn conflicted_files(&self) -> Result<Vec<ConflictedFile>, GitError>
pub fn conflicted_files(&self) -> Result<Vec<ConflictedFile>, GitError>
列出所有处于冲突状态的文件。
Sourcepub fn read_stage(&self, path: &str, stage: u8) -> Result<Vec<u8>, GitError>
pub fn read_stage(&self, path: &str, stage: u8) -> Result<Vec<u8>, GitError>
读取冲突文件某个 stage 的完整内容(1=base,2=ours,3=theirs)。
Sourcepub fn read_blobs(&self, oids: &[&str]) -> Result<Vec<Vec<u8>>, GitError>
pub fn read_blobs(&self, oids: &[&str]) -> Result<Vec<Vec<u8>>, GitError>
用单个 git cat-file --batch 进程批量读取 blob,按请求顺序返回。
逐文件 git show 每个 stage 都要 spawn 一次进程(实测 ~12-16ms),
冲突文件多时进入 TUI 前的等待明显;这里改为请求-应答式复用一个
子进程,进程开销从 O(3N) 降为 O(1)。
Sourcepub fn list_branches(&self) -> Result<Vec<String>, GitError>
pub fn list_branches(&self) -> Result<Vec<String>, GitError>
列出可作为 merge / rebase 目标的分支:本地 + 远程跟踪, 排除当前分支与 HEAD 符号引用。
Sourcepub fn recent_commits(
&self,
others_only: bool,
limit: usize,
) -> Result<Vec<String>, GitError>
pub fn recent_commits( &self, others_only: bool, limit: usize, ) -> Result<Vec<String>, GitError>
最近提交列表(--oneline 行,首列为短 hash),提交选择器用。
others_only 为 true 时只列不在当前分支上的提交(cherry-pick 候选),
否则列当前分支的最近提交(revert 候选)。
空仓库等无提交可列的场景返回空列表而非报错。
Sourcepub fn vitals(&self) -> Result<RepoVitals, GitError>
pub fn vitals(&self) -> Result<RepoVitals, GitError>
探测仓库体征:分支、改动数、贮藏数、待推送数与提交总数。
五个查询彼此独立,而每次 git 进程 spawn 约 12-16ms,串行累计的
延迟在打开菜单时可感知,因此用作用域线程并行执行,总耗时约等于
最慢的一次;ahead / level 在无上游 / 空仓库时查询会非零退出,
分别归一化为 None / 0 而非报错。
Sourcepub fn stage_resolved(&self, path: &str, content: &[u8]) -> Result<(), GitError>
pub fn stage_resolved(&self, path: &str, content: &[u8]) -> Result<(), GitError>
将解决后的内容写入工作区文件并 git add。
Sourcepub fn continue_op(&self, state: RepoState) -> Result<ExitStatus, GitError>
pub fn continue_op(&self, state: RepoState) -> Result<ExitStatus, GitError>
继续当前 merge / rebase(冲突全部解决后调用)。
以透传模式执行:git 与钩子的输出(含颜色)实时流向用户终端。 返回退出码而非直接判错:rebase –continue 在下一个 commit 冲突时也会非零退出,是否算失败由调用方结合冲突探测决定。
Auto Trait Implementations§
impl Freeze for Git
impl RefUnwindSafe for Git
impl Send for Git
impl Sync for Git
impl Unpin for Git
impl UnsafeUnpin for Git
impl UnwindSafe for Git
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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