mod journal_ops;
#[cfg(feature = "lfs")]
mod lfs;
#[cfg(not(feature = "lfs"))]
#[path = "lfs_stub.rs"]
mod lfs;
mod mutate;
mod predict;
mod reads;
mod reflog_ops;
mod repo;
mod reword;
mod snapshot_ops;
mod staging;
use std::path::{Path, PathBuf};
use gitpoulpi_cli_backend::SystemGitBackend;
pub fn count_commits_in_process(repo: &RepoRef, opts: &LogOptions) -> Result<u64> {
reads::count_commits(repo, opts)
}
use gitpoulpi_core::domain::rewrite::{
Recipe, RewriteOutcome, RewritePlan, RewriteProgressSink, RunId,
};
use gitpoulpi_core::domain::*;
use gitpoulpi_core::{GitBackend, Result};
pub fn native_index_tree(repo: &RepoRef) -> Result<Oid> {
journal_ops::index_tree(repo)
}
pub fn native_index_fingerprint(repo: &RepoRef) -> Result<String> {
let git = repo::open(repo)?;
let mut index = git.index().map_err(repo::map_err)?;
index.read(true).map_err(repo::map_err)?;
let mut text: Vec<u8> = Vec::new();
for entry in index.iter() {
let stage = (entry.flags >> 12) & 0x3;
text.extend_from_slice(format!("{:o} {} {stage}\t", entry.mode, entry.id).as_bytes());
text.extend_from_slice(&entry.path);
text.push(b'\n');
}
let id = git2::Oid::hash_object(git2::ObjectType::Blob, &text).map_err(repo::map_err)?;
Ok(id.to_string())
}
pub fn native_snapshot_create(repo: &RepoRef, paths: &[String]) -> Result<Snapshot> {
snapshot_ops::snapshot_create(repo, paths)
}
pub fn native_ref_snapshot(repo: &RepoRef, scope: &RefScope) -> Result<RefSnapshot> {
journal_ops::ref_snapshot(repo, scope)
}
pub fn native_stashes(repo: &RepoRef) -> Result<Vec<Stash>> {
reads::stashes(repo)
}
pub fn native_path_hashes(repo: &RepoRef, paths: &[String]) -> Result<Vec<PathHash>> {
snapshot_ops::path_hashes(repo, paths)
}
pub struct Git2Backend {
fallback: SystemGitBackend,
}
impl Git2Backend {
pub fn new() -> Self {
Self {
fallback: SystemGitBackend::new(),
}
}
}
fn touches_worktree_or_index(target: &DiffTarget) -> bool {
matches!(
target,
DiffTarget::WorkingTreeVsIndex | DiffTarget::IndexVsHead
)
}
impl Git2Backend {
pub fn without_lfs() -> Self {
Self {
fallback: SystemGitBackend::without_lfs(),
}
}
}
impl Default for Git2Backend {
fn default() -> Self {
Self::new()
}
}
macro_rules! forward_to_fallback {
($(
$(#[$meta:meta])*
fn $name:ident(&self $(, $arg:ident: $ty:ty)* $(,)?) -> $ret:ty;
)*) => {
$(
$(#[$meta])*
fn $name(&self $(, $arg: $ty)*) -> $ret {
self.fallback.$name($($arg),*)
}
)*
};
}
#[async_trait::async_trait]
impl GitBackend for Git2Backend {
fn name(&self) -> &'static str {
"git2"
}
fn discover(&self, path: &Path) -> Result<DiscoveredRepo> {
repo::discover(path)
}
fn init(&self, path: &Path, opts: &InitOptions) -> Result<RepoRef> {
repo::init(path, opts)
}
fn status(&self, repo: &RepoRef) -> Result<WorkingTree> {
if lfs::is_active(repo) {
self.fallback.status(repo)
} else {
reads::status(repo)
}
}
fn log(&self, repo: &RepoRef, opts: &LogOptions) -> Result<CommitGraph> {
if opts.paths.is_empty() {
reads::log(repo, opts)
} else {
self.fallback.log(repo, opts)
}
}
fn count_commits(&self, repo: &RepoRef, opts: &LogOptions) -> Result<u64> {
self.fallback.count_commits(repo, opts)
}
fn diff(&self, repo: &RepoRef, target: DiffTarget) -> Result<Vec<FileDiff>> {
if touches_worktree_or_index(&target) && lfs::is_active(repo) {
self.fallback.diff(repo, target)
} else {
reads::diff(repo, target)
}
}
fn diff_files(&self, repo: &RepoRef, target: DiffTarget) -> Result<DiffFileList> {
if touches_worktree_or_index(&target) && lfs::is_active(repo) {
self.fallback.diff_files(repo, target)
} else {
reads::diff_files(repo, target)
}
}
fn commit_stats(&self, repo: &RepoRef, ids: &[Oid]) -> Result<Vec<CommitStat>> {
reads::commit_stats(repo, ids)
}
fn commit_messages(
&self,
repo: &RepoRef,
query: &gitpoulpi_core::domain::CommitMessagesQuery,
) -> Result<gitpoulpi_core::domain::CommitMessages> {
reads::commit_messages(repo, query)
}
fn diff_paths(
&self,
repo: &RepoRef,
target: DiffTarget,
paths: &[PathBuf],
) -> Result<Vec<FileDiff>> {
if touches_worktree_or_index(&target) && lfs::is_active(repo) {
self.fallback.diff_paths(repo, target, paths)
} else {
reads::diff_paths(repo, target, paths)
}
}
fn refs(&self, repo: &RepoRef) -> Result<Vec<Ref>> {
reads::refs(repo)
}
fn ref_snapshot(&self, repo: &RepoRef, scope: &RefScope) -> Result<RefSnapshot> {
journal_ops::ref_snapshot(repo, scope)
}
fn update_refs(
&self,
repo: &RepoRef,
updates: &[RefUpdate],
reflog_message: &str,
) -> Result<()> {
journal_ops::update_refs(repo, updates, reflog_message)
}
fn index_tree(&self, repo: &RepoRef) -> Result<Oid> {
journal_ops::index_tree(repo)
}
fn index_restore(&self, repo: &RepoRef, tree: Oid) -> Result<()> {
journal_ops::index_restore(repo, tree)
}
fn snapshot_create(&self, repo: &RepoRef, paths: &[String]) -> Result<Snapshot> {
snapshot_ops::snapshot_create(repo, paths)
}
fn snapshot_restore(&self, repo: &RepoRef, snapshot: Oid, paths: &[String]) -> Result<()> {
snapshot_ops::snapshot_restore(repo, snapshot, paths)
}
fn path_hashes(&self, repo: &RepoRef, paths: &[String]) -> Result<Vec<PathHash>> {
snapshot_ops::path_hashes(repo, paths)
}
fn blob_bytes(&self, repo: &RepoRef, oid: Oid) -> Result<Vec<u8>> {
reflog_ops::blob_bytes(repo, oid)
}
fn reflog(
&self,
repo: &RepoRef,
refname: &str,
skip: usize,
limit: usize,
) -> Result<gitpoulpi_core::domain::ReflogPage> {
reflog_ops::reflog(repo, refname, skip, limit)
}
fn config_section(&self, repo: &RepoRef, section: &str) -> Result<Vec<(String, String)>> {
journal_ops::config_section(repo, section)
}
fn remote_dependents(&self, repo: &RepoRef, remote: &str) -> Result<Vec<String>> {
journal_ops::remote_dependents(repo, remote)
}
fn set_config_section(
&self,
repo: &RepoRef,
section: &str,
entries: &[(String, String)],
) -> Result<()> {
journal_ops::set_config_section(repo, section, entries)
}
fn stashes(&self, repo: &RepoRef) -> Result<Vec<Stash>> {
reads::stashes(repo)
}
fn remotes(&self, repo: &RepoRef) -> Result<Vec<Remote>> {
reads::remotes(repo)
}
fn worktrees(&self, repo: &RepoRef) -> Result<Vec<Worktree>> {
if cfg!(feature = "worktree") {
reads::worktrees(repo)
} else {
Err(gitpoulpi_core::Error::NotBuilt {
feature: "worktree",
})
}
}
fn submodules(&self, repo: &RepoRef) -> Result<Vec<Submodule>> {
#[cfg(feature = "submodule")]
{
reads::submodules(repo)
}
#[cfg(not(feature = "submodule"))]
{
let _ = repo;
Err(gitpoulpi_core::Error::NotBuilt {
feature: "submodule",
})
}
}
fn resolve(&self, repo: &RepoRef, rev: &str) -> Result<Oid> {
reads::resolve(repo, rev)
}
fn merge_base(&self, repo: &RepoRef, a: Oid, b: Oid) -> Result<Option<Oid>> {
reads::merge_base(repo, a, b)
}
fn ahead_behind(&self, repo: &RepoRef, tip: Oid, base: Oid) -> Result<(u32, u32)> {
reads::ahead_behind(repo, tip, base)
}
fn cherry_counts(&self, repo: &RepoRef, local: Oid, remote: Oid) -> Result<(u32, u32)> {
self.fallback.cherry_counts(repo, local, remote)
}
fn predict_merge_conflicts(
&self,
repo: &RepoRef,
ours: Oid,
theirs: Oid,
) -> Result<Vec<String>> {
predict::predict_merge_conflicts(repo, ours, theirs)
}
fn read_blob(&self, repo: &RepoRef, path: &Path, source: &BlobSource) -> Result<Blob> {
reads::read_blob(repo, path, source)
}
fn read_blob_bytes(
&self,
repo: &RepoRef,
path: &Path,
source: &BlobSource,
max: u64,
) -> Result<gitpoulpi_core::domain::BlobBytes> {
reads::read_blob_bytes(repo, path, source, max)
}
fn list_tree(&self, repo: &RepoRef, at: Oid) -> Result<Vec<PathBuf>> {
reads::list_tree(repo, at)
}
fn grep_tree(
&self,
repo: &RepoRef,
at: Oid,
terms: &[String],
max_hits: usize,
) -> Result<Vec<gitpoulpi_core::domain::GrepHit>> {
reads::grep_tree(repo, at, terms, max_hits)
}
fn mailmap_resolve(
&self,
repo: &RepoRef,
idents: &[gitpoulpi_core::domain::rewrite::Ident],
) -> Result<Vec<gitpoulpi_core::domain::rewrite::Ident>> {
reads::mailmap_resolve(repo, idents)
}
fn blame(&self, repo: &RepoRef, path: &Path, at: Oid) -> Result<Blame> {
reads::blame(repo, path, at)
}
fn file_history(
&self,
repo: &RepoRef,
path: &Path,
start: Oid,
skip: usize,
limit: usize,
) -> Result<gitpoulpi_core::domain::FileHistoryPage> {
self.fallback.file_history(repo, path, start, skip, limit)
}
fn stage(&self, repo: &RepoRef, target: &StageTarget) -> Result<()> {
if !staging::handles(target) || lfs::is_active(repo) {
return self.fallback.stage(repo, target);
}
match staging::stage(repo, target) {
Err(gitpoulpi_core::Error::Unsupported { .. }) => self.fallback.stage(repo, target),
other => other,
}
}
fn unstage(&self, repo: &RepoRef, target: &StageTarget) -> Result<()> {
if !staging::handles(target) || lfs::is_active(repo) {
return self.fallback.unstage(repo, target);
}
match staging::unstage(repo, target) {
Err(gitpoulpi_core::Error::Unsupported { .. }) => self.fallback.unstage(repo, target),
other => other,
}
}
fn commit(&self, repo: &RepoRef, message: &str, opts: &CommitOptions) -> Result<Oid> {
if mutate::has_pending_sequencer_commit(repo) || mutate::has_commit_hooks(repo) {
return self.fallback.commit(repo, message, opts);
}
mutate::commit(repo, message, opts)
}
fn checkout(&self, repo: &RepoRef, target: &CheckoutTarget) -> Result<()> {
self.fallback.checkout(repo, target)
}
fn discard(&self, repo: &RepoRef, paths: &[String]) -> Result<()> {
if lfs::is_active(repo) {
return self.fallback.discard(repo, paths);
}
staging::discard(repo, paths)
}
fn branch_create(&self, repo: &RepoRef, name: &str, at: Oid) -> Result<()> {
mutate::branch_create(repo, name, at)
}
fn branch_create_tracking(
&self,
repo: &RepoRef,
local_name: &str,
upstream: &str,
) -> Result<()> {
self.fallback
.branch_create_tracking(repo, local_name, upstream)
}
fn branch_delete(&self, repo: &RepoRef, name: &str) -> Result<()> {
mutate::branch_delete(repo, name)
}
fn branch_rename(&self, repo: &RepoRef, old_name: &str, new_name: &str) -> Result<()> {
mutate::branch_rename(repo, old_name, new_name)
}
fn branch_set_upstream(
&self,
repo: &RepoRef,
branch: &str,
upstream: Option<&str>,
) -> Result<()> {
mutate::branch_set_upstream(repo, branch, upstream)
}
fn fast_forward(
&self,
repo: &RepoRef,
branch: &str,
target: Oid,
) -> Result<FastForwardOutcome> {
if lfs::is_active(repo) || mutate::is_checked_out(repo, branch) {
return self.fallback.fast_forward(repo, branch, target);
}
mutate::fast_forward(repo, branch, target)
}
fn tag_create(
&self,
repo: &RepoRef,
name: &str,
at: Oid,
annotated_message: Option<&str>,
) -> Result<()> {
mutate::tag_create(repo, name, at, annotated_message)
}
fn tag_delete(&self, repo: &RepoRef, name: &str) -> Result<()> {
mutate::tag_delete(repo, name)
}
fn tag_annotate(&self, repo: &RepoRef, name: &str, message: &str) -> Result<()> {
mutate::tag_annotate(repo, name, message)
}
fn tag_move(&self, repo: &RepoRef, name: &str, to: Oid, force: bool) -> Result<()> {
mutate::tag_move(repo, name, to, force)
}
fn tag_merge_branch(
&self,
repo: &RepoRef,
name: &str,
branch: &str,
message: Option<&str>,
) -> Result<Oid> {
mutate::tag_merge_branch(repo, name, branch, message)
}
async fn tag_push(
&self,
repo: &RepoRef,
remote: &str,
selection: &TagSelection,
) -> Result<PushOutcome> {
self.fallback.tag_push(repo, remote, selection).await
}
fn tag_take_remote(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
self.fallback.tag_take_remote(repo, remote, name)
}
async fn tag_force_push(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
self.fallback.tag_force_push(repo, remote, name).await
}
async fn tag_delete_remote(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
self.fallback.tag_delete_remote(repo, remote, name).await
}
async fn tag_fetch(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
self.fallback.tag_fetch(repo, remote, name).await
}
async fn branch_delete_remote(&self, repo: &RepoRef, remote: &str, name: &str) -> Result<()> {
self.fallback.branch_delete_remote(repo, remote, name).await
}
async fn remote_ref_value(
&self,
repo: &RepoRef,
remote: &str,
full_ref: &str,
) -> Result<Option<Oid>> {
self.fallback.remote_ref_value(repo, remote, full_ref).await
}
async fn remote_ref_update(
&self,
repo: &RepoRef,
remote: &str,
full_ref: &str,
new: Option<Oid>,
expect: Option<Oid>,
) -> Result<()> {
self.fallback
.remote_ref_update(repo, remote, full_ref, new, expect)
.await
}
fn rebase_state(&self, repo: &RepoRef) -> Result<Option<RebaseState>> {
if reads::provably_no_rebase(repo) {
return Ok(None);
}
self.fallback.rebase_state(repo)
}
fn reset(&self, repo: &RepoRef, target: Oid, mode: ResetMode) -> Result<()> {
if mode != ResetMode::Soft {
return self.fallback.reset(repo, target, mode);
}
mutate::reset(repo, target, mode)
}
fn reword(&self, repo: &RepoRef, commit: Oid, message: &str) -> Result<RewordOutcome> {
reword::reword(repo, commit, message)
}
fn amend_commit(
&self,
repo: &RepoRef,
commit: Oid,
amend: &gitpoulpi_core::domain::CommitAmend,
) -> Result<RewordOutcome> {
reword::amend_commit(repo, commit, amend, "amend")
}
fn split_source(&self, repo: &RepoRef, commit: Oid) -> Result<SplitSource> {
self.fallback.split_source(repo, commit)
}
fn split_commit(&self, repo: &RepoRef, req: &SplitCommit) -> Result<SplitOutcome> {
self.fallback.split_commit(repo, req)
}
fn rewrite_preview(
&self,
repo: &RepoRef,
recipe: &Recipe,
progress: RewriteProgressSink<'_>,
) -> Result<RewritePlan> {
self.fallback.rewrite_preview(repo, recipe, progress)
}
fn rewrite_apply(&self, repo: &RepoRef, plan: &RewritePlan) -> Result<RewriteOutcome> {
self.fallback.rewrite_apply(repo, plan)
}
fn rewrite_extract(
&self,
repo: &RepoRef,
plan: &RewritePlan,
target: &std::path::Path,
) -> Result<RewriteOutcome> {
self.fallback.rewrite_extract(repo, plan, target)
}
fn rewrite_load(&self, repo: &RepoRef, run: &RunId) -> Result<Option<RewritePlan>> {
self.fallback.rewrite_load(repo, run)
}
fn rewrite_record(
&self,
repo: &RepoRef,
run: &RunId,
) -> Result<gitpoulpi_core::domain::rewrite::RewriteRecord> {
self.fallback.rewrite_record(repo, run)
}
fn rewrite_maps(
&self,
repo: &RepoRef,
run: &RunId,
out: Option<&std::path::Path>,
) -> Result<gitpoulpi_core::domain::rewrite::RewriteMaps> {
self.fallback.rewrite_maps(repo, run, out)
}
async fn push_rewritten(
&self,
repo: &RepoRef,
req: &gitpoulpi_core::domain::rewrite::PushRewritten,
) -> Result<gitpoulpi_core::domain::rewrite::PushRewrittenOutcome> {
self.fallback.push_rewritten(repo, req).await
}
fn rewrite_purge(
&self,
repo: &RepoRef,
req: &gitpoulpi_core::domain::rewrite::PurgeRequest,
progress: gitpoulpi_core::domain::rewrite::PurgeProgressSink<'_>,
) -> Result<gitpoulpi_core::domain::rewrite::PurgeOutcome> {
self.fallback.rewrite_purge(repo, req, progress)
}
fn rewrite_blob_diff(
&self,
repo: &RepoRef,
run: &RunId,
commit: Oid,
path: &str,
) -> Result<gitpoulpi_core::domain::rewrite::BlobChange> {
self.fallback.rewrite_blob_diff(repo, run, commit, path)
}
fn rewrite_script_check(
&self,
repo: &RepoRef,
script: &gitpoulpi_core::domain::rewrite::ScriptRef,
policy: &gitpoulpi_core::domain::rewrite::ScriptPolicy,
) -> Result<gitpoulpi_core::domain::rewrite::script::ScriptCheck> {
self.fallback.rewrite_script_check(repo, script, policy)
}
fn rewrite_script_test(
&self,
repo: &RepoRef,
script: &gitpoulpi_core::domain::rewrite::ScriptRef,
policy: &gitpoulpi_core::domain::rewrite::ScriptPolicy,
commits: &[Oid],
) -> Result<Vec<gitpoulpi_core::domain::rewrite::script::ScriptTestRow>> {
self.fallback
.rewrite_script_test(repo, script, policy, commits)
}
fn rewrite_analyze(
&self,
repo: &RepoRef,
scope: &gitpoulpi_core::domain::rewrite::Scope,
top: u32,
progress: gitpoulpi_core::domain::rewrite::RewriteProgressSink<'_>,
) -> Result<gitpoulpi_core::domain::rewrite::SizeAnalysis> {
self.fallback.rewrite_analyze(repo, scope, top, progress)
}
fn rewrite_scan_secrets(
&self,
repo: &RepoRef,
scope: &gitpoulpi_core::domain::rewrite::Scope,
progress: gitpoulpi_core::domain::rewrite::RewriteProgressSink<'_>,
) -> Result<gitpoulpi_core::domain::rewrite::SecretScan> {
self.fallback.rewrite_scan_secrets(repo, scope, progress)
}
fn rewrite_discard(&self, repo: &RepoRef, run: &RunId) -> Result<()> {
self.fallback.rewrite_discard(repo, run)
}
fn set_network_auth(&self, repo: &RepoRef, auth: Option<NetworkAuth>) {
self.fallback.set_network_auth(repo, auth);
}
async fn remote_access_check(
&self,
repo: &RepoRef,
remote: &str,
opts: &RemoteAccessOptions,
) -> Result<RemoteAccessReport> {
self.fallback.remote_access_check(repo, remote, opts).await
}
async fn fetch(
&self,
repo: &RepoRef,
remote: &str,
opts: &FetchOptions,
) -> Result<FetchOutcome> {
self.fallback.fetch(repo, remote, opts).await
}
async fn fetch_all(&self, repo: &RepoRef, opts: &FetchOptions) -> Result<FetchOutcome> {
self.fallback.fetch_all(repo, opts).await
}
async fn fetch_ref_as_branch(
&self,
repo: &RepoRef,
remote: &str,
remote_ref: &str,
branch: &str,
) -> Result<FetchOutcome> {
self.fallback
.fetch_ref_as_branch(repo, remote, remote_ref, branch)
.await
}
async fn fetch_refspec(
&self,
repo: &RepoRef,
remote: &str,
refspec: &str,
) -> Result<FetchOutcome> {
self.fallback.fetch_refspec(repo, remote, refspec).await
}
async fn pull(&self, repo: &RepoRef, opts: &PullOptions) -> Result<PullOutcome> {
self.fallback.pull(repo, opts).await
}
async fn pull_fetch(&self, repo: &RepoRef, opts: &PullOptions) -> Result<()> {
self.fallback.pull_fetch(repo, opts).await
}
async fn pull_integrate(&self, repo: &RepoRef, opts: &PullOptions) -> Result<PullOutcome> {
self.fallback.pull_integrate(repo, opts).await
}
async fn push(&self, repo: &RepoRef, remote: &str, opts: &PushOptions) -> Result<PushOutcome> {
self.fallback.push(repo, remote, opts).await
}
async fn push_for_review(
&self,
repo: &RepoRef,
remote: &str,
branch: &str,
topic: Option<&str>,
) -> Result<PushOutcome> {
self.fallback
.push_for_review(repo, remote, branch, topic)
.await
}
async fn clone(&self, url: &str, dest: &Path, opts: &CloneOptions) -> Result<RepoRef> {
self.fallback.clone(url, dest, opts).await
}
async fn clone_with_progress(
&self,
url: &str,
dest: &Path,
opts: &CloneOptions,
progress: CloneProgressSink<'_>,
) -> Result<RepoRef> {
self.fallback
.clone_with_progress(url, dest, opts, progress)
.await
}
fn remote_set_url(&self, repo: &RepoRef, name: &str, url: &str) -> Result<()> {
if !mutate::remote_has_url(repo, name)? {
return self.fallback.remote_set_url(repo, name, url);
}
mutate::remote_set_url(repo, name, url)
}
fn remote_set_push_url(&self, repo: &RepoRef, name: &str, url: Option<&str>) -> Result<()> {
if !mutate::remote_has_url(repo, name)? {
return self.fallback.remote_set_push_url(repo, name, url);
}
mutate::remote_set_push_url(repo, name, url)
}
fn ssh_command(&self, repo: &RepoRef) -> Result<Option<String>> {
mutate::ssh_command(repo)
}
fn set_ssh_command(&self, repo: &RepoRef, command: Option<&str>) -> Result<()> {
mutate::set_ssh_command(repo, command)
}
fn repo_config(&self, repo: &RepoRef, key: &str) -> Result<Option<String>> {
mutate::repo_config(repo, key)
}
fn sparse_checkout_status(&self, repo: &RepoRef) -> Result<SparseState> {
self.fallback.sparse_checkout_status(repo)
}
fn sparse_checkout_set(&self, repo: &RepoRef, dirs: &[String]) -> Result<()> {
self.fallback.sparse_checkout_set(repo, dirs)
}
fn sparse_checkout_disable(&self, repo: &RepoRef) -> Result<()> {
self.fallback.sparse_checkout_disable(repo)
}
fn set_repo_config(&self, repo: &RepoRef, key: &str, value: Option<&str>) -> Result<()> {
mutate::set_repo_config(repo, key, value)
}
fn config_entries(&self, repo: &RepoRef, prefixes: &[&str]) -> Result<Vec<(String, String)>> {
mutate::config_entries(repo, prefixes)
}
fn lfs_files(&self, repo: &RepoRef, at: Option<Oid>) -> Result<Vec<LfsFile>> {
lfs::lfs_files(repo, at)
}
async fn lfs_locks(&self, repo: &RepoRef, remote: &str) -> Result<Vec<LfsLock>> {
self.fallback.lfs_locks(repo, remote).await
}
async fn lfs_lock(&self, repo: &RepoRef, remote: &str, path: &Path) -> Result<LfsLock> {
self.fallback.lfs_lock(repo, remote, path).await
}
async fn lfs_unlock(
&self,
repo: &RepoRef,
remote: &str,
path: &Path,
force: bool,
) -> Result<()> {
self.fallback.lfs_unlock(repo, remote, path, force).await
}
async fn lfs_fetch(
&self,
repo: &RepoRef,
remote: &str,
opts: &LfsFetchOptions,
progress: LfsProgressSink<'_>,
) -> Result<()> {
self.fallback.lfs_fetch(repo, remote, opts, progress).await
}
async fn lfs_pull(
&self,
repo: &RepoRef,
remote: &str,
progress: LfsProgressSink<'_>,
) -> Result<()> {
self.fallback.lfs_pull(repo, remote, progress).await
}
async fn lfs_checkout(
&self,
repo: &RepoRef,
paths: &[PathBuf],
progress: LfsProgressSink<'_>,
) -> Result<()> {
self.fallback.lfs_checkout(repo, paths, progress).await
}
async fn lfs_push(
&self,
repo: &RepoRef,
remote: &str,
opts: &LfsPushOptions,
progress: LfsProgressSink<'_>,
) -> Result<()> {
self.fallback.lfs_push(repo, remote, opts, progress).await
}
fn conflicts(&self, repo: &RepoRef) -> Result<Vec<ConflictSet>> {
if reads::provably_no_conflicts(repo) {
return Ok(Vec::new());
}
self.fallback.conflicts(repo)
}
fn conflict_entries(&self, repo: &RepoRef) -> Result<Vec<ConflictEntry>> {
reads::conflict_entries(repo)
}
fn merge_document(&self, repo: &RepoRef, path: &Path) -> Result<MergeDocument> {
reads::merge_document(repo, path)
}
forward_to_fallback! {
fn lost_commits(
&self,
repo: &RepoRef,
opts: &gitpoulpi_core::domain::LostCommitOptions,
) -> Result<gitpoulpi_core::domain::LostCommitsPage>;
fn move_head_keep(&self, repo: &RepoRef, branch: &str, from: Oid, to: Oid) -> Result<()>;
fn delete_files(&self, repo: &RepoRef, paths: &[String]) -> Result<()>;
fn convert_files(
&self,
repo: &RepoRef,
paths: &[String],
op: gitpoulpi_core::textconv::ConvertOp,
) -> Result<gitpoulpi_core::textconv::ConvertReport>;
fn gitignore_add(&self, repo: &RepoRef, pattern: &str, file: Option<&str>) -> Result<bool>;
fn gitattributes_treat(
&self,
repo: &RepoRef,
paths: &[String],
scope: gitpoulpi_core::domain::RuleScope,
file: Option<&str>,
treat: gitpoulpi_core::domain::Treat,
) -> Result<gitpoulpi_core::domain::AttributesWrite>;
fn binary_paths(&self, repo: &RepoRef, paths: &[String]) -> Result<Vec<bool>>;
fn mailmap_identities(
&self,
repo: &RepoRef,
scope: &gitpoulpi_core::domain::rewrite::Scope,
options: &gitpoulpi_core::domain::rewrite::ScopeOptions,
) -> Result<gitpoulpi_core::domain::rewrite::IdentityList>;
fn mailmap_add(
&self,
repo: &RepoRef,
canonical: &gitpoulpi_core::domain::rewrite::Ident,
from: &[gitpoulpi_core::domain::rewrite::Ident],
file: Option<&str>,
) -> Result<gitpoulpi_core::domain::rewrite::MailmapAdded>;
fn patch_files(&self, repo: &RepoRef, patch: &Path) -> Result<Vec<String>>;
fn discard_part(&self, repo: &RepoRef, target: &DiscardTarget) -> Result<()>;
fn submodule_init(&self, repo: &RepoRef, paths: &[String]) -> Result<()>;
fn submodule_update(&self, repo: &RepoRef, opts: &SubmoduleUpdateOptions) -> Result<()>;
fn worktree_add(
&self,
repo: &RepoRef,
path: &Path,
opts: &WorktreeAddOptions,
) -> Result<Worktree>;
fn worktree_changes(&self, repo: &RepoRef, path: &Path) -> Result<Vec<WorktreeChange>>;
fn worktree_remove(
&self,
repo: &RepoRef,
path: &Path,
opts: &WorktreeRemoveOptions,
) -> Result<WorktreeRemoved>;
fn patch_create(
&self,
repo: &RepoRef,
source: &PatchSource,
dest: &Path,
) -> Result<PatchCreated>;
fn patch_apply(&self, repo: &RepoRef, patch: &Path) -> Result<PatchApplied>;
fn apply_commit_to_worktree(&self, repo: &RepoRef, commit: Oid) -> Result<PatchApplied>;
fn merge(&self, repo: &RepoRef, from: &Ref, opts: &MergeOptions) -> Result<MergeOutcome>;
fn rebase(&self, repo: &RepoRef, onto: &Ref, opts: &RebaseOptions) -> Result<RebaseOutcome>;
fn rebase_plan(&self, repo: &RepoRef, upstream: Option<Oid>) -> Result<RebasePlanDraft>;
fn rebase_interactive(
&self,
repo: &RepoRef,
req: &InteractiveRebase,
) -> Result<RebaseOutcome>;
fn rebase_continue(&self, repo: &RepoRef) -> Result<RebaseOutcome>;
fn rebase_skip(&self, repo: &RepoRef) -> Result<RebaseOutcome>;
fn rebase_abort(&self, repo: &RepoRef) -> Result<()>;
fn cherry_pick(
&self,
repo: &RepoRef,
commits: &[Oid],
opts: &CherryPickOptions,
) -> Result<CherryPickOutcome>;
fn revert(&self, repo: &RepoRef, commit: Oid, mainline: Option<u32>) -> Result<RevertOutcome>;
fn stash_push(
&self,
repo: &RepoRef,
message: Option<&str>,
include_untracked: bool,
) -> Result<Option<StashId>>;
fn stash_push_paths(
&self,
repo: &RepoRef,
message: Option<&str>,
paths: &[String],
) -> Result<Option<StashId>>;
fn stash_pop(&self, repo: &RepoRef, id: StashId) -> Result<()>;
fn stash_apply(&self, repo: &RepoRef, id: StashId) -> Result<()>;
fn stash_drop(&self, repo: &RepoRef, id: StashId) -> Result<()>;
fn stash_store(&self, repo: &RepoRef, commit: Oid, message: &str) -> Result<()>;
fn stash_from_commit(
&self,
repo: &RepoRef,
commit: Oid,
message: Option<&str>,
) -> Result<Oid>;
fn stash_paths(&self, repo: &RepoRef, commit: Oid) -> Result<Vec<String>>;
fn remote_add(&self, repo: &RepoRef, name: &str, url: &str) -> Result<()>;
fn remote_remove(&self, repo: &RepoRef, name: &str) -> Result<()>;
fn leftover_remotes(&self, repo: &RepoRef) -> Result<Vec<String>>;
fn remote_rename(&self, repo: &RepoRef, old_name: &str, new_name: &str) -> Result<()>;
fn lfs_status(&self, repo: &RepoRef) -> Result<LfsRepoStatus>;
fn rewrite_tools(&self, repo: &RepoRef, fresh: bool) -> Result<gitpoulpi_core::domain::rewrite::RewriteTools>;
fn rewrite_check_signing(&self, repo: &RepoRef) -> Result<gitpoulpi_core::domain::rewrite::SigningCheck>;
fn lfs_install(&self, repo: &RepoRef, scope: LfsInstallScope) -> Result<()>;
fn lfs_track(
&self,
repo: &RepoRef,
patterns: &[String],
opts: &LfsTrackOptions,
) -> Result<Vec<LfsPattern>>;
fn lfs_untrack(&self, repo: &RepoRef, patterns: &[String]) -> Result<Vec<LfsPattern>>;
fn lfs_prune(&self, repo: &RepoRef) -> Result<()>;
fn resolve_conflict(
&self,
repo: &RepoRef,
path: &Path,
resolution: ConflictResolution,
opts: &ResolveOptions,
) -> Result<()>;
fn unresolve_conflict(&self, repo: &RepoRef, path: &Path, entry: &ConflictEntry)
-> Result<()>;
fn operation_state(&self, repo: &RepoRef) -> Result<Option<OperationState>>;
fn operation_abort(&self, repo: &RepoRef) -> Result<()>;
fn am_continue(&self, repo: &RepoRef) -> Result<AmOutcome>;
fn am_skip(&self, repo: &RepoRef) -> Result<AmOutcome>;
fn am_abort(&self, repo: &RepoRef) -> Result<()>;
fn index_lock(&self, repo: &RepoRef) -> Result<Option<IndexLock>>;
fn index_lock_remove(&self, repo: &RepoRef) -> Result<()>;
fn operation_skip(&self, repo: &RepoRef) -> Result<()>;
}
}