Skip to main content

gitpoulpi_cli_backend/
lib.rs

1//! GitBackend implementation driving an installed system `git` binary.
2//!
3//! Used both standalone (user-selectable `default_backend = "system"`) and
4//! as the CLI-fallback target inside `Git2Backend` for operations git2
5//! doesn't support well. Parses only machine-readable git output
6//! (`--porcelain=v2 -z`, NUL-delimited log formats) -- never human text.
7
8mod branch;
9mod cancel_cleanup;
10mod checkout;
11mod command_run;
12mod commit;
13mod conflicts;
14mod content;
15mod convert_ops;
16mod count;
17mod diff;
18mod discard;
19mod discover;
20mod file_history;
21mod history;
22mod history_ops;
23mod index_scan;
24mod journal_ops;
25#[cfg(feature = "lfs")]
26mod lfs;
27#[cfg(not(feature = "lfs"))]
28#[path = "lfs_stub.rs"]
29mod lfs;
30#[cfg(feature = "lfs")]
31mod lfs_locks;
32#[cfg(not(feature = "lfs"))]
33#[path = "lfs_locks_stub.rs"]
34mod lfs_locks;
35#[cfg(feature = "lfs")]
36mod lfs_network;
37#[cfg(not(feature = "lfs"))]
38#[path = "lfs_network_stub.rs"]
39mod lfs_network;
40mod log;
41mod messages;
42mod network;
43mod operation;
44mod patch;
45mod patch_file;
46mod predict;
47mod process;
48mod prune;
49mod rebase_interactive;
50mod reflog_ops;
51mod refs;
52mod remote_access;
53mod remote_ref;
54mod remotes;
55mod reset;
56mod reword;
57mod rewrite;
58mod rule_files;
59mod scoped_config;
60mod snapshot_ops;
61mod sparse;
62mod split;
63mod staging;
64mod stash_ops;
65mod stashes;
66mod status;
67mod stream;
68mod stuck;
69#[cfg(feature = "submodule")]
70mod submodules;
71#[cfg(not(feature = "submodule"))]
72#[path = "submodules_stub.rs"]
73mod submodules;
74mod tags;
75mod tools;
76mod tree_kill;
77mod worktree_list;
78#[cfg(feature = "worktree")]
79mod worktrees;
80#[cfg(not(feature = "worktree"))]
81#[path = "worktrees_stub.rs"]
82mod worktrees;
83
84use std::path::{Path, PathBuf};
85
86use gitpoulpi_core::domain::rewrite::{
87    Recipe, RewriteOutcome, RewritePlan, RewriteProgressSink, RunId,
88};
89use gitpoulpi_core::domain::*;
90use gitpoulpi_core::{GitBackend, Result};
91
92/// Which remotes are known to hold a tag at a given commit, given the
93/// remote-tag mirror.
94///
95/// Re-exported because `Git2Backend` reads the same mirror refs through
96/// libgit2 and must reach the identical verdict - the rule that a
97/// differing oid does *not* count as pushed lives in exactly one place,
98/// not once per backend.
99pub use cancel_cleanup::remove_stale_transfer_files;
100pub use command_run::{run_command, CommandOutput, CommandRunError};
101pub use content::{body_of, lfs_local_object};
102pub use reflog_ops::reflog_via_git;
103pub use refs::{apply_tag_sync, tag_sync_for};
104pub use scoped_config::{
105    config_entries, credential_helper_entries, global_ssh_program, machine_wide_helpers,
106    ssh_command_entries, ConfigEntry,
107};
108
109/// The config-section rules of the undo journal, shared with
110/// `Git2Backend` so the two accept exactly the same sections.
111pub use journal_ops::{
112    check_section as check_config_section, dependents_in as remote_dependents_in,
113    in_section as config_key_in_section, is_key_section as is_config_key_section,
114};
115
116/// How network commands get HTTPS credentials; the daemon sets it from
117/// `credentials.https_mode` before each network operation.
118pub use process::{
119    credential_mode, expand_home, git_program, set_credential_mode, set_ssh_key,
120    ssh_key_command as global_ssh_key_command, CredentialMode,
121};
122
123/// The part of `merge_document` after the stages are read, and the label
124/// reader, shared with `Git2Backend` (which reads the stages natively).
125pub use conflicts::{document_from_stages, git_dir};
126/// Process-wide spawn counter (see `process`), the perf guard's currency.
127pub use process::total_spawn_count;
128pub use prune::prune_empty_parents;
129pub use snapshot_ops::{
130    normalize_all as snapshot_normalize_all, remove_any as snapshot_remove_any,
131    walk as snapshot_walk, write_file as snapshot_write_file, MODE_LINK,
132};
133
134pub struct SystemGitBackend {
135    /// Cached `git lfs version` (see `lfs::LfsProbe`).
136    lfs_probe: lfs::LfsProbe,
137    /// Cached probes of the programs a history rewrite may use.
138    tool_probe: tools::ToolProbe,
139}
140
141impl SystemGitBackend {
142    pub fn new() -> Self {
143        Self {
144            lfs_probe: lfs::LfsProbe::default(),
145            tool_probe: tools::ToolProbe::default(),
146        }
147    }
148}
149
150impl SystemGitBackend {
151    /// A backend that behaves as if `git-lfs` is not installed, whatever
152    /// the machine has: every LFS operation that needs the program fails
153    /// with `Error::LfsUnavailable`. A constructor rather than the
154    /// `GITPOULPI_GIT_LFS` variable so tests running in parallel cannot
155    /// affect each other.
156    pub fn without_lfs() -> Self {
157        Self {
158            lfs_probe: lfs::LfsProbe::forced(LfsBinary::Missing),
159            tool_probe: tools::ToolProbe::forced(
160                gitpoulpi_core::domain::rewrite::Tool::GitLfs,
161                gitpoulpi_core::domain::rewrite::ToolStatus::Missing,
162            ),
163        }
164    }
165}
166
167impl Default for SystemGitBackend {
168    fn default() -> Self {
169        Self::new()
170    }
171}
172
173#[async_trait::async_trait]
174impl GitBackend for SystemGitBackend {
175    fn name(&self) -> &'static str {
176        "system"
177    }
178
179    fn discover(&self, path: &Path) -> Result<DiscoveredRepo> {
180        discover::discover(path)
181    }
182
183    fn init(&self, path: &Path, opts: &InitOptions) -> Result<RepoRef> {
184        discover::init(path, opts)
185    }
186
187    fn status(&self, repo: &RepoRef) -> Result<WorkingTree> {
188        status::status(repo)
189    }
190    fn log(&self, repo: &RepoRef, opts: &LogOptions) -> Result<CommitGraph> {
191        log::log(repo, opts)
192    }
193    fn count_commits(&self, repo: &RepoRef, opts: &LogOptions) -> Result<u64> {
194        count::count_commits(repo, opts)
195    }
196    fn ref_snapshot(&self, repo: &RepoRef, scope: &RefScope) -> Result<RefSnapshot> {
197        journal_ops::ref_snapshot(repo, scope)
198    }
199    fn update_refs(
200        &self,
201        repo: &RepoRef,
202        updates: &[RefUpdate],
203        reflog_message: &str,
204    ) -> Result<()> {
205        journal_ops::update_refs(repo, updates, reflog_message)
206    }
207    fn move_head_keep(&self, repo: &RepoRef, branch: &str, from: Oid, to: Oid) -> Result<()> {
208        journal_ops::move_head_keep(repo, branch, from, to)
209    }
210    fn index_tree(&self, repo: &RepoRef) -> Result<Oid> {
211        snapshot_ops::index_tree(repo)
212    }
213    fn index_restore(&self, repo: &RepoRef, tree: Oid) -> Result<()> {
214        snapshot_ops::index_restore(repo, tree)
215    }
216    fn snapshot_create(&self, repo: &RepoRef, paths: &[String]) -> Result<Snapshot> {
217        snapshot_ops::snapshot_create(repo, paths)
218    }
219    fn snapshot_restore(&self, repo: &RepoRef, snapshot: Oid, paths: &[String]) -> Result<()> {
220        snapshot_ops::snapshot_restore(repo, snapshot, paths)
221    }
222    fn path_hashes(&self, repo: &RepoRef, paths: &[String]) -> Result<Vec<PathHash>> {
223        snapshot_ops::path_hashes(repo, paths)
224    }
225    fn blob_bytes(&self, repo: &RepoRef, oid: Oid) -> Result<Vec<u8>> {
226        reflog_ops::blob_bytes(repo, oid)
227    }
228    fn reflog(
229        &self,
230        repo: &RepoRef,
231        refname: &str,
232        skip: usize,
233        limit: usize,
234    ) -> Result<gitpoulpi_core::domain::ReflogPage> {
235        reflog_ops::reflog(repo, refname, skip, limit)
236    }
237    fn lost_commits(
238        &self,
239        repo: &RepoRef,
240        opts: &gitpoulpi_core::domain::LostCommitOptions,
241    ) -> Result<gitpoulpi_core::domain::LostCommitsPage> {
242        reflog_ops::lost_commits(repo, opts)
243    }
244    fn delete_files(&self, repo: &RepoRef, paths: &[String]) -> Result<()> {
245        snapshot_ops::delete_files(repo, paths)
246    }
247    fn convert_files(
248        &self,
249        repo: &RepoRef,
250        paths: &[String],
251        op: gitpoulpi_core::textconv::ConvertOp,
252    ) -> Result<gitpoulpi_core::textconv::ConvertReport> {
253        convert_ops::convert_files(repo, paths, op)
254    }
255    fn gitignore_add(&self, repo: &RepoRef, pattern: &str, file: Option<&str>) -> Result<bool> {
256        rule_files::gitignore_add(repo, pattern, file)
257    }
258    fn gitattributes_treat(
259        &self,
260        repo: &RepoRef,
261        paths: &[String],
262        scope: gitpoulpi_core::domain::RuleScope,
263        file: Option<&str>,
264        treat: gitpoulpi_core::domain::Treat,
265    ) -> Result<gitpoulpi_core::domain::AttributesWrite> {
266        rule_files::gitattributes_treat(repo, paths, scope, file, treat)
267    }
268    fn mailmap_resolve(
269        &self,
270        repo: &RepoRef,
271        idents: &[gitpoulpi_core::domain::rewrite::Ident],
272    ) -> Result<Vec<gitpoulpi_core::domain::rewrite::Ident>> {
273        history::mailmap_resolve(repo, idents)
274    }
275    fn mailmap_identities(
276        &self,
277        repo: &RepoRef,
278        scope: &gitpoulpi_core::domain::rewrite::Scope,
279        options: &gitpoulpi_core::domain::rewrite::ScopeOptions,
280    ) -> Result<gitpoulpi_core::domain::rewrite::IdentityList> {
281        history::mailmap_identities(repo, scope, options)
282    }
283    fn mailmap_add(
284        &self,
285        repo: &RepoRef,
286        canonical: &gitpoulpi_core::domain::rewrite::Ident,
287        from: &[gitpoulpi_core::domain::rewrite::Ident],
288        file: Option<&str>,
289    ) -> Result<gitpoulpi_core::domain::rewrite::MailmapAdded> {
290        history::mailmap_add(repo, canonical, from, file)
291    }
292    fn binary_paths(&self, repo: &RepoRef, paths: &[String]) -> Result<Vec<bool>> {
293        rule_files::binary_paths(repo, paths)
294    }
295    fn patch_files(&self, repo: &RepoRef, patch: &Path) -> Result<Vec<String>> {
296        snapshot_ops::patch_files(repo, patch)
297    }
298    fn config_section(&self, repo: &RepoRef, section: &str) -> Result<Vec<(String, String)>> {
299        journal_ops::config_section(repo, section)
300    }
301    fn config_sections(
302        &self,
303        repo: &RepoRef,
304        sections: &[String],
305    ) -> Result<Vec<gitpoulpi_core::backend::ConfigSection>> {
306        journal_ops::config_sections(repo, sections)
307    }
308    fn remote_dependents(&self, repo: &RepoRef, remote: &str) -> Result<Vec<String>> {
309        journal_ops::remote_dependents(repo, remote)
310    }
311    fn set_config_section(
312        &self,
313        repo: &RepoRef,
314        section: &str,
315        entries: &[(String, String)],
316    ) -> Result<()> {
317        journal_ops::set_config_section(repo, section, entries)
318    }
319    fn diff(&self, repo: &RepoRef, target: DiffTarget) -> Result<Vec<FileDiff>> {
320        diff::diff(repo, target)
321    }
322    fn diff_files(&self, repo: &RepoRef, target: DiffTarget) -> Result<DiffFileList> {
323        diff::diff_files(repo, target)
324    }
325    fn commit_stats(&self, repo: &RepoRef, ids: &[Oid]) -> Result<Vec<CommitStat>> {
326        diff::commit_stats(repo, ids)
327    }
328    fn commit_messages(
329        &self,
330        repo: &RepoRef,
331        query: &gitpoulpi_core::domain::CommitMessagesQuery,
332    ) -> Result<gitpoulpi_core::domain::CommitMessages> {
333        messages::commit_messages(repo, query)
334    }
335    fn diff_paths(
336        &self,
337        repo: &RepoRef,
338        target: DiffTarget,
339        paths: &[PathBuf],
340    ) -> Result<Vec<FileDiff>> {
341        diff::diff_paths(repo, target, paths)
342    }
343    fn refs(&self, repo: &RepoRef) -> Result<Vec<Ref>> {
344        refs::refs(repo)
345    }
346    fn stashes(&self, repo: &RepoRef) -> Result<Vec<Stash>> {
347        stashes::stashes(repo)
348    }
349    fn remotes(&self, repo: &RepoRef) -> Result<Vec<Remote>> {
350        remotes::remotes(repo)
351    }
352    fn leftover_remotes(&self, repo: &RepoRef) -> Result<Vec<String>> {
353        remotes::leftover_remotes(repo)
354    }
355    fn worktrees(&self, repo: &RepoRef) -> Result<Vec<Worktree>> {
356        worktrees::worktrees(repo)
357    }
358    fn submodules(&self, repo: &RepoRef) -> Result<Vec<Submodule>> {
359        submodules::submodules(repo)
360    }
361    fn submodule_init(&self, repo: &RepoRef, paths: &[String]) -> Result<()> {
362        submodules::submodule_init(repo, paths)
363    }
364    fn submodule_update(&self, repo: &RepoRef, opts: &SubmoduleUpdateOptions) -> Result<()> {
365        submodules::submodule_update(repo, opts)
366    }
367    fn resolve(&self, repo: &RepoRef, rev: &str) -> Result<Oid> {
368        refs::resolve(repo, rev)
369    }
370    fn merge_base(&self, repo: &RepoRef, a: Oid, b: Oid) -> Result<Option<Oid>> {
371        refs::merge_base(repo, a, b)
372    }
373    fn ahead_behind(&self, repo: &RepoRef, tip: Oid, base: Oid) -> Result<(u32, u32)> {
374        refs::ahead_behind(repo, tip, base)
375    }
376    fn cherry_counts(&self, repo: &RepoRef, local: Oid, remote: Oid) -> Result<(u32, u32)> {
377        refs::cherry_counts(repo, local, remote)
378    }
379    fn predict_merge_conflicts(
380        &self,
381        repo: &RepoRef,
382        ours: Oid,
383        theirs: Oid,
384    ) -> Result<Vec<String>> {
385        predict::predict_merge_conflicts(repo, ours, theirs)
386    }
387    fn read_blob(&self, repo: &RepoRef, path: &Path, source: &BlobSource) -> Result<Blob> {
388        content::read_blob(repo, path, source)
389    }
390    fn read_blob_bytes(
391        &self,
392        repo: &RepoRef,
393        path: &Path,
394        source: &BlobSource,
395        max: u64,
396    ) -> Result<gitpoulpi_core::domain::BlobBytes> {
397        content::read_blob_bytes(repo, path, source, max)
398    }
399    fn list_tree(&self, repo: &RepoRef, at: Oid) -> Result<Vec<PathBuf>> {
400        content::list_tree(repo, at)
401    }
402    fn grep_tree(
403        &self,
404        repo: &RepoRef,
405        at: Oid,
406        terms: &[String],
407        max_hits: usize,
408    ) -> Result<Vec<gitpoulpi_core::domain::GrepHit>> {
409        content::grep_tree(repo, at, terms, max_hits)
410    }
411
412    fn blame(&self, repo: &RepoRef, path: &Path, at: Oid) -> Result<Blame> {
413        content::blame(repo, path, at)
414    }
415    fn file_history(
416        &self,
417        repo: &RepoRef,
418        path: &Path,
419        start: Oid,
420        skip: usize,
421        limit: usize,
422    ) -> Result<gitpoulpi_core::domain::FileHistoryPage> {
423        file_history::file_history(repo, path, start, skip, limit)
424    }
425    fn stage(&self, repo: &RepoRef, target: &StageTarget) -> Result<()> {
426        staging::stage(repo, target)
427    }
428    fn unstage(&self, repo: &RepoRef, target: &StageTarget) -> Result<()> {
429        staging::unstage(repo, target)
430    }
431    fn commit(&self, repo: &RepoRef, message: &str, opts: &CommitOptions) -> Result<Oid> {
432        commit::commit(repo, message, opts)
433    }
434    fn checkout(&self, repo: &RepoRef, target: &CheckoutTarget) -> Result<()> {
435        checkout::checkout(repo, target)
436    }
437    fn discard(&self, repo: &RepoRef, paths: &[String]) -> Result<()> {
438        discard::discard(repo, paths)
439    }
440    fn discard_part(&self, repo: &RepoRef, target: &DiscardTarget) -> Result<()> {
441        staging::discard_part(repo, target)
442    }
443    fn branch_create(&self, repo: &RepoRef, name: &str, at: Oid) -> Result<()> {
444        branch::branch_create(repo, name, at)
445    }
446    fn branch_create_tracking(
447        &self,
448        repo: &RepoRef,
449        local_name: &str,
450        upstream: &str,
451    ) -> Result<()> {
452        branch::branch_create_tracking(repo, local_name, upstream)
453    }
454    fn branch_delete(&self, repo: &RepoRef, name: &str) -> Result<()> {
455        branch::branch_delete(repo, name)
456    }
457    fn branch_rename(&self, repo: &RepoRef, old_name: &str, new_name: &str) -> Result<()> {
458        branch::branch_rename(repo, old_name, new_name)
459    }
460    fn branch_set_upstream(
461        &self,
462        repo: &RepoRef,
463        branch: &str,
464        upstream: Option<&str>,
465    ) -> Result<()> {
466        branch::branch_set_upstream(repo, branch, upstream)
467    }
468    fn fast_forward(
469        &self,
470        repo: &RepoRef,
471        branch: &str,
472        target: Oid,
473    ) -> Result<FastForwardOutcome> {
474        branch::fast_forward(repo, branch, target)
475    }
476    fn worktree_add(
477        &self,
478        repo: &RepoRef,
479        path: &Path,
480        opts: &WorktreeAddOptions,
481    ) -> Result<Worktree> {
482        worktrees::worktree_add(repo, path, opts)
483    }
484    fn worktree_changes(&self, repo: &RepoRef, path: &Path) -> Result<Vec<WorktreeChange>> {
485        worktrees::worktree_changes(repo, path)
486    }
487    fn worktree_remove(
488        &self,
489        repo: &RepoRef,
490        path: &Path,
491        opts: &WorktreeRemoveOptions,
492    ) -> Result<WorktreeRemoved> {
493        worktrees::worktree_remove(repo, path, opts)
494    }
495    fn patch_create(
496        &self,
497        repo: &RepoRef,
498        source: &PatchSource,
499        dest: &Path,
500    ) -> Result<PatchCreated> {
501        patch_file::patch_create(repo, source, dest)
502    }
503    fn patch_apply(&self, repo: &RepoRef, patch: &Path) -> Result<PatchApplied> {
504        patch_file::patch_apply(repo, patch)
505    }
506
507    fn apply_commit_to_worktree(&self, repo: &RepoRef, commit: Oid) -> Result<PatchApplied> {
508        patch_file::apply_commit_to_worktree(repo, commit)
509    }
510    fn tag_create(
511        &self,
512        repo: &RepoRef,
513        name: &str,
514        at: Oid,
515        annotated_message: Option<&str>,
516    ) -> Result<()> {
517        branch::tag_create(repo, name, at, annotated_message)
518    }
519    fn tag_delete(&self, repo: &RepoRef, name: &str) -> Result<()> {
520        branch::tag_delete(repo, name)
521    }
522    fn tag_annotate(&self, repo: &RepoRef, name: &str, message: &str) -> Result<()> {
523        tags::tag_annotate(repo, name, message)
524    }
525    async fn tag_push(
526        &self,
527        repo: &RepoRef,
528        remote: &str,
529        selection: &TagSelection,
530    ) -> Result<PushOutcome> {
531        tags::tag_push(repo, remote, selection).await
532    }
533    async fn tag_delete_remote(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
534        tags::tag_delete_remote(repo, remote, name).await
535    }
536    async fn tag_fetch(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
537        tags::tag_fetch(repo, remote, name).await
538    }
539    async fn branch_delete_remote(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
540        branch::branch_delete_remote(repo, remote, name).await
541    }
542    async fn remote_ref_value(
543        &self,
544        repo: &RepoRef,
545        remote: &str,
546        full_ref: &str,
547    ) -> Result<Option<Oid>> {
548        remote_ref::remote_ref_value(repo, remote, full_ref).await
549    }
550    async fn remote_ref_update(
551        &self,
552        repo: &RepoRef,
553        remote: &str,
554        full_ref: &str,
555        new: Option<Oid>,
556        expect: Option<Oid>,
557    ) -> Result<()> {
558        remote_ref::remote_ref_update(repo, remote, full_ref, new, expect).await
559    }
560    fn merge(&self, repo: &RepoRef, from: &Ref, opts: &MergeOptions) -> Result<MergeOutcome> {
561        history_ops::merge(repo, from, opts)
562    }
563    fn rebase(&self, repo: &RepoRef, onto: &Ref, opts: &RebaseOptions) -> Result<RebaseOutcome> {
564        history_ops::rebase(repo, onto, opts)
565    }
566    fn rebase_plan(&self, repo: &RepoRef, upstream: Option<Oid>) -> Result<RebasePlanDraft> {
567        rebase_interactive::rebase_plan(repo, upstream)
568    }
569    fn rebase_interactive(&self, repo: &RepoRef, req: &InteractiveRebase) -> Result<RebaseOutcome> {
570        rebase_interactive::rebase_interactive(repo, req)
571    }
572    fn rebase_state(&self, repo: &RepoRef) -> Result<Option<RebaseState>> {
573        rebase_interactive::rebase_state(repo)
574    }
575    fn rebase_continue(&self, repo: &RepoRef) -> Result<RebaseOutcome> {
576        rebase_interactive::rebase_continue(repo)
577    }
578    fn rebase_skip(&self, repo: &RepoRef) -> Result<RebaseOutcome> {
579        rebase_interactive::rebase_skip(repo)
580    }
581    fn rebase_abort(&self, repo: &RepoRef) -> Result<()> {
582        rebase_interactive::rebase_abort(repo)
583    }
584    fn cherry_pick(
585        &self,
586        repo: &RepoRef,
587        commits: &[Oid],
588        opts: &CherryPickOptions,
589    ) -> Result<CherryPickOutcome> {
590        history_ops::cherry_pick(repo, commits, opts)
591    }
592    fn revert(&self, repo: &RepoRef, commit: Oid, mainline: Option<u32>) -> Result<RevertOutcome> {
593        history_ops::revert(repo, commit, mainline)
594    }
595    fn reset(&self, repo: &RepoRef, target: Oid, mode: ResetMode) -> Result<()> {
596        reset::reset(repo, target, mode)
597    }
598    fn reword(&self, repo: &RepoRef, commit: Oid, message: &str) -> Result<RewordOutcome> {
599        reword::reword(repo, commit, message)
600    }
601    fn amend_commit(
602        &self,
603        repo: &RepoRef,
604        commit: Oid,
605        amend: &gitpoulpi_core::domain::CommitAmend,
606    ) -> Result<RewordOutcome> {
607        reword::amend_commit(repo, commit, amend, "amend")
608    }
609    fn split_source(&self, repo: &RepoRef, commit: Oid) -> Result<SplitSource> {
610        split::split_source(repo, commit)
611    }
612    fn split_commit(&self, repo: &RepoRef, req: &SplitCommit) -> Result<SplitOutcome> {
613        split::split_commit(repo, req)
614    }
615    // History rewrite (`history/`): the engine is the system git's, the
616    // git2 backend delegates here.
617    fn rewrite_preview(
618        &self,
619        repo: &RepoRef,
620        recipe: &Recipe,
621        progress: RewriteProgressSink<'_>,
622    ) -> Result<RewritePlan> {
623        history::preview(repo, recipe, &self.tool_probe, progress)
624    }
625    fn rewrite_apply(&self, repo: &RepoRef, plan: &RewritePlan) -> Result<RewriteOutcome> {
626        history::apply(repo, plan)
627    }
628    fn rewrite_extract(
629        &self,
630        repo: &RepoRef,
631        plan: &RewritePlan,
632        target: &std::path::Path,
633    ) -> Result<RewriteOutcome> {
634        history::extract_to(repo, plan, target, &self.tool_probe)
635    }
636    fn rewrite_load(&self, repo: &RepoRef, run: &RunId) -> Result<Option<RewritePlan>> {
637        history::load(repo, run)
638    }
639    fn rewrite_record(
640        &self,
641        repo: &RepoRef,
642        run: &RunId,
643    ) -> Result<gitpoulpi_core::domain::rewrite::RewriteRecord> {
644        history::record(repo, run)
645    }
646    fn rewrite_maps(
647        &self,
648        repo: &RepoRef,
649        run: &RunId,
650        out: Option<&Path>,
651    ) -> Result<gitpoulpi_core::domain::rewrite::RewriteMaps> {
652        history::maps(repo, run, out)
653    }
654    async fn push_rewritten(
655        &self,
656        repo: &RepoRef,
657        req: &gitpoulpi_core::domain::rewrite::PushRewritten,
658    ) -> Result<gitpoulpi_core::domain::rewrite::PushRewrittenOutcome> {
659        history::push_rewritten(repo, req).await
660    }
661    fn rewrite_purge(
662        &self,
663        repo: &RepoRef,
664        req: &gitpoulpi_core::domain::rewrite::PurgeRequest,
665        progress: gitpoulpi_core::domain::rewrite::PurgeProgressSink<'_>,
666    ) -> Result<gitpoulpi_core::domain::rewrite::PurgeOutcome> {
667        history::purge(repo, req, progress)
668    }
669    fn rewrite_blob_diff(
670        &self,
671        repo: &RepoRef,
672        run: &RunId,
673        commit: Oid,
674        path: &str,
675    ) -> Result<gitpoulpi_core::domain::rewrite::BlobChange> {
676        history::blob_diff(repo, run, commit, path)
677    }
678    fn rewrite_script_check(
679        &self,
680        repo: &RepoRef,
681        script: &gitpoulpi_core::domain::rewrite::ScriptRef,
682        policy: &gitpoulpi_core::domain::rewrite::ScriptPolicy,
683    ) -> Result<gitpoulpi_core::domain::rewrite::script::ScriptCheck> {
684        history::script_check(repo, script, policy, &self.tool_probe)
685    }
686    fn rewrite_script_test(
687        &self,
688        repo: &RepoRef,
689        script: &gitpoulpi_core::domain::rewrite::ScriptRef,
690        policy: &gitpoulpi_core::domain::rewrite::ScriptPolicy,
691        commits: &[Oid],
692    ) -> Result<Vec<gitpoulpi_core::domain::rewrite::script::ScriptTestRow>> {
693        history::script_test(repo, script, policy, &self.tool_probe, commits)
694    }
695    fn rewrite_scan_secrets(
696        &self,
697        repo: &RepoRef,
698        scope: &gitpoulpi_core::domain::rewrite::Scope,
699        progress: gitpoulpi_core::domain::rewrite::RewriteProgressSink<'_>,
700    ) -> Result<gitpoulpi_core::domain::rewrite::SecretScan> {
701        history::scan_secrets(repo, scope, progress)
702    }
703    fn rewrite_analyze(
704        &self,
705        repo: &RepoRef,
706        scope: &gitpoulpi_core::domain::rewrite::Scope,
707        top: u32,
708        progress: gitpoulpi_core::domain::rewrite::RewriteProgressSink<'_>,
709    ) -> Result<gitpoulpi_core::domain::rewrite::SizeAnalysis> {
710        history::analyze(repo, scope, top, progress)
711    }
712    fn rewrite_discard(&self, repo: &RepoRef, run: &RunId) -> Result<()> {
713        history::discard(repo, run)
714    }
715    fn stash_push(
716        &self,
717        repo: &RepoRef,
718        message: Option<&str>,
719        include_untracked: bool,
720    ) -> Result<Option<StashId>> {
721        stash_ops::stash_push(repo, message, include_untracked)
722    }
723    fn stash_push_paths(
724        &self,
725        repo: &RepoRef,
726        message: Option<&str>,
727        paths: &[String],
728    ) -> Result<Option<StashId>> {
729        stash_ops::stash_push_paths(repo, message, paths)
730    }
731    fn stash_pop(&self, repo: &RepoRef, id: StashId) -> Result<()> {
732        stash_ops::stash_pop(repo, id)
733    }
734    fn stash_apply(&self, repo: &RepoRef, id: StashId) -> Result<()> {
735        stash_ops::stash_apply(repo, id)
736    }
737    fn stash_drop(&self, repo: &RepoRef, id: StashId) -> Result<()> {
738        stash_ops::stash_drop(repo, id)
739    }
740    fn stash_store(&self, repo: &RepoRef, commit: Oid, message: &str) -> Result<()> {
741        stash_ops::stash_store(repo, commit, message)
742    }
743
744    fn stash_from_commit(&self, repo: &RepoRef, commit: Oid, message: Option<&str>) -> Result<Oid> {
745        stash_ops::stash_from_commit(repo, commit, message)
746    }
747    fn stash_paths(&self, repo: &RepoRef, commit: Oid) -> Result<Vec<String>> {
748        stash_ops::stash_paths(repo, commit)
749    }
750    fn set_network_auth(&self, repo: &RepoRef, auth: Option<NetworkAuth>) {
751        process::set_network_auth(&repo.root, auth);
752    }
753    async fn remote_access_check(
754        &self,
755        repo: &RepoRef,
756        remote: &str,
757        opts: &RemoteAccessOptions,
758    ) -> Result<RemoteAccessReport> {
759        remote_access::check(repo, remote, opts).await
760    }
761    async fn fetch(
762        &self,
763        repo: &RepoRef,
764        remote: &str,
765        opts: &FetchOptions,
766    ) -> Result<FetchOutcome> {
767        network::fetch(repo, remote, opts).await
768    }
769    async fn fetch_all(&self, repo: &RepoRef, opts: &FetchOptions) -> Result<FetchOutcome> {
770        network::fetch_all(repo, opts).await
771    }
772    async fn fetch_ref_as_branch(
773        &self,
774        repo: &RepoRef,
775        remote: &str,
776        remote_ref: &str,
777        branch: &str,
778    ) -> Result<FetchOutcome> {
779        network::fetch_ref_as_branch(repo, remote, remote_ref, branch).await
780    }
781    async fn fetch_refspec(
782        &self,
783        repo: &RepoRef,
784        remote: &str,
785        refspec: &str,
786    ) -> Result<FetchOutcome> {
787        network::fetch_refspec(repo, remote, refspec).await
788    }
789    async fn pull(&self, repo: &RepoRef, opts: &PullOptions) -> Result<PullOutcome> {
790        network::pull(repo, opts).await
791    }
792    async fn pull_fetch(&self, repo: &RepoRef, opts: &PullOptions) -> Result<()> {
793        network::pull_fetch(repo, opts).await
794    }
795    async fn pull_integrate(&self, repo: &RepoRef, opts: &PullOptions) -> Result<PullOutcome> {
796        network::pull_integrate(repo, opts).await
797    }
798    async fn push(&self, repo: &RepoRef, remote: &str, opts: &PushOptions) -> Result<PushOutcome> {
799        network::push(repo, remote, opts).await
800    }
801    async fn push_for_review(
802        &self,
803        repo: &RepoRef,
804        remote: &str,
805        branch: &str,
806        topic: Option<&str>,
807    ) -> Result<PushOutcome> {
808        network::push_for_review(repo, remote, branch, topic).await
809    }
810    async fn clone(&self, url: &str, dest: &Path, opts: &CloneOptions) -> Result<RepoRef> {
811        network::clone(url, dest, opts, &self.lfs_probe).await
812    }
813    async fn clone_with_progress(
814        &self,
815        url: &str,
816        dest: &Path,
817        opts: &CloneOptions,
818        progress: CloneProgressSink<'_>,
819    ) -> Result<RepoRef> {
820        network::clone_with_progress(url, dest, opts, &self.lfs_probe, progress).await
821    }
822    fn remote_add(&self, repo: &RepoRef, name: &str, url: &str) -> Result<()> {
823        network::remote_add(repo, name, url)
824    }
825    fn remote_remove(&self, repo: &RepoRef, name: &str) -> Result<()> {
826        remotes::remote_remove(repo, name)
827    }
828    fn remote_rename(&self, repo: &RepoRef, old_name: &str, new_name: &str) -> Result<()> {
829        remotes::remote_rename(repo, old_name, new_name)
830    }
831    fn remote_set_url(&self, repo: &RepoRef, name: &str, url: &str) -> Result<()> {
832        remotes::remote_set_url(repo, name, url)
833    }
834    fn remote_set_push_url(&self, repo: &RepoRef, name: &str, url: Option<&str>) -> Result<()> {
835        remotes::remote_set_push_url(repo, name, url)
836    }
837    fn ssh_command(&self, repo: &RepoRef) -> Result<Option<String>> {
838        remotes::ssh_command(repo)
839    }
840    fn set_ssh_command(&self, repo: &RepoRef, command: Option<&str>) -> Result<()> {
841        remotes::set_ssh_command(repo, command)
842    }
843    fn repo_config(&self, repo: &RepoRef, key: &str) -> Result<Option<String>> {
844        remotes::repo_config(repo, key)
845    }
846    fn sparse_checkout_status(&self, repo: &RepoRef) -> Result<SparseState> {
847        sparse::status(repo)
848    }
849    fn sparse_checkout_set(&self, repo: &RepoRef, dirs: &[String]) -> Result<()> {
850        sparse::set(repo, dirs)
851    }
852    fn sparse_checkout_disable(&self, repo: &RepoRef) -> Result<()> {
853        sparse::disable(repo)
854    }
855    fn set_repo_config(&self, repo: &RepoRef, key: &str, value: Option<&str>) -> Result<()> {
856        remotes::set_repo_config(repo, key, value)
857    }
858    fn config_entries(&self, repo: &RepoRef, prefixes: &[&str]) -> Result<Vec<(String, String)>> {
859        remotes::config_entries(repo, prefixes)
860    }
861    fn rewrite_tools(
862        &self,
863        repo: &RepoRef,
864        fresh: bool,
865    ) -> Result<gitpoulpi_core::domain::rewrite::RewriteTools> {
866        tools::rewrite_tools(repo, &self.tool_probe, fresh)
867    }
868    fn rewrite_check_signing(
869        &self,
870        repo: &RepoRef,
871    ) -> Result<gitpoulpi_core::domain::rewrite::SigningCheck> {
872        history::check_signing(repo, &self.tool_probe)
873    }
874    fn lfs_status(&self, repo: &RepoRef) -> Result<LfsRepoStatus> {
875        lfs::lfs_status(repo, &self.lfs_probe)
876    }
877    fn lfs_files(&self, repo: &RepoRef, at: Option<Oid>) -> Result<Vec<LfsFile>> {
878        lfs::lfs_files(repo, at)
879    }
880    fn lfs_install(&self, repo: &RepoRef, scope: LfsInstallScope) -> Result<()> {
881        lfs::lfs_install(repo, &self.lfs_probe, scope)
882    }
883    fn lfs_track(
884        &self,
885        repo: &RepoRef,
886        patterns: &[String],
887        opts: &LfsTrackOptions,
888    ) -> Result<Vec<LfsPattern>> {
889        lfs::lfs_track(repo, &self.lfs_probe, patterns, opts)
890    }
891    fn lfs_untrack(&self, repo: &RepoRef, patterns: &[String]) -> Result<Vec<LfsPattern>> {
892        lfs::lfs_untrack(repo, &self.lfs_probe, patterns)
893    }
894    fn lfs_prune(&self, repo: &RepoRef) -> Result<()> {
895        lfs::lfs_prune(repo, &self.lfs_probe)
896    }
897    async fn lfs_locks(&self, repo: &RepoRef, remote: &str) -> Result<Vec<LfsLock>> {
898        lfs_locks::lfs_locks(repo, &self.lfs_probe, remote).await
899    }
900    async fn lfs_lock(&self, repo: &RepoRef, remote: &str, path: &Path) -> Result<LfsLock> {
901        lfs_locks::lfs_lock(repo, &self.lfs_probe, remote, path).await
902    }
903    async fn lfs_unlock(
904        &self,
905        repo: &RepoRef,
906        remote: &str,
907        path: &Path,
908        force: bool,
909    ) -> Result<()> {
910        lfs_locks::lfs_unlock(repo, &self.lfs_probe, remote, path, force).await
911    }
912    async fn lfs_fetch(
913        &self,
914        repo: &RepoRef,
915        remote: &str,
916        opts: &LfsFetchOptions,
917        progress: LfsProgressSink<'_>,
918    ) -> Result<()> {
919        lfs_network::lfs_fetch(repo, &self.lfs_probe, remote, opts, progress).await
920    }
921    async fn lfs_pull(
922        &self,
923        repo: &RepoRef,
924        remote: &str,
925        progress: LfsProgressSink<'_>,
926    ) -> Result<()> {
927        lfs_network::lfs_pull(repo, &self.lfs_probe, remote, progress).await
928    }
929    async fn lfs_checkout(
930        &self,
931        repo: &RepoRef,
932        paths: &[PathBuf],
933        progress: LfsProgressSink<'_>,
934    ) -> Result<()> {
935        lfs_network::lfs_checkout(repo, &self.lfs_probe, paths, progress).await
936    }
937    async fn lfs_push(
938        &self,
939        repo: &RepoRef,
940        remote: &str,
941        opts: &LfsPushOptions,
942        progress: LfsProgressSink<'_>,
943    ) -> Result<()> {
944        lfs_network::lfs_push(repo, &self.lfs_probe, remote, opts, progress).await
945    }
946    fn conflicts(&self, repo: &RepoRef) -> Result<Vec<ConflictSet>> {
947        conflicts::conflicts(repo)
948    }
949    fn conflict_entries(&self, repo: &RepoRef) -> Result<Vec<ConflictEntry>> {
950        conflicts::conflict_entries(repo)
951    }
952    fn merge_document(&self, repo: &RepoRef, path: &Path) -> Result<MergeDocument> {
953        conflicts::merge_document(repo, path)
954    }
955    fn resolve_conflict(
956        &self,
957        repo: &RepoRef,
958        path: &Path,
959        resolution: ConflictResolution,
960        opts: &ResolveOptions,
961    ) -> Result<()> {
962        conflicts::resolve_conflict(repo, path, resolution, opts)
963    }
964    fn unresolve_conflict(&self, repo: &RepoRef, path: &Path, entry: &ConflictEntry) -> Result<()> {
965        conflicts::unresolve_conflict(repo, path, entry)
966    }
967    fn operation_state(&self, repo: &RepoRef) -> Result<Option<OperationState>> {
968        operation::operation_state(repo)
969    }
970    fn operation_abort(&self, repo: &RepoRef) -> Result<()> {
971        operation::operation_abort(repo)
972    }
973    fn am_continue(&self, repo: &RepoRef) -> Result<AmOutcome> {
974        stuck::am_continue(repo)
975    }
976    fn am_skip(&self, repo: &RepoRef) -> Result<AmOutcome> {
977        stuck::am_skip(repo)
978    }
979    fn am_abort(&self, repo: &RepoRef) -> Result<()> {
980        stuck::am_abort(repo)
981    }
982    fn index_lock(&self, repo: &RepoRef) -> Result<Option<IndexLock>> {
983        stuck::index_lock(repo)
984    }
985    fn index_lock_remove(&self, repo: &RepoRef) -> Result<()> {
986        stuck::index_lock_remove(repo)
987    }
988    fn operation_skip(&self, repo: &RepoRef) -> Result<()> {
989        operation::operation_skip(repo)
990    }
991}