1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! What:
//! The cheap-worktree ladder around one `git worktree add`: what runs before real Git and after it, on Linux; on other
//! systems the ladder does nothing and Git's own checkout stands.
//! Why:
//! `doc/planning/cli-git-btrfs-worktree.md` designs the ladder and measures it: a snapshot of a clean subvolume
//! worktree, then clones of its tracked files, then Git's own checkout. The lifecycle of the copy
//! (`worktree_copy.rs`) calls this one module, so the rungs stay out of its settlement and recovery code.
//!
//! In TS you'd write (pseudocode):
//! ```ts
//! const ladder = beginLadder(plan, context, identity);
//! const git = await runGit(ladder.firstStep());
//! const { git: status, carried } = await ladder.finish(git, ...);
//! ```
#[cfg(target_os = "linux")]
pub use super::worktree_ladder_run::{Ladder, LadderResult, begin_ladder};
/// What:
/// The ladder on a system without btrfs subvolumes and snapshots: nothing is prepared and nothing is settled.
/// Why:
/// Git's own checkout stands there, and the lifecycle calls the same four names.
///
/// In TS you'd write (pseudocode):
/// ```ts
/// const ladder = beginLadder(plan, context, identity); // does nothing
/// ```
#[cfg(not(target_os = "linux"))]
mod other {
use super::super::transaction_git::GitContext;
use super::super::worktree_add_plan::AddPlan;
use super::super::worktree_copy::{GitRunner, GitStatus, GitStep};
use super::super::worktree_identity::WorktreeIdentity;
use std::io::Write;
use std::path::PathBuf;
/// The ladder that does nothing.
pub struct Ladder;
/// What the ladder tells the lifecycle after Git.
pub struct LadderResult {
/// Git's status for the person.
pub git: GitStatus,
/// The destination that received the source's ignored state with the snapshot.
pub carried: Option<PathBuf>,
}
/// Prepare nothing.
pub fn begin_ladder(_plan: Option<&AddPlan>, _context: &GitContext, _identity: &WorktreeIdentity) -> Ladder {
return Ladder;
}
impl Ladder {
/// The person's arguments.
pub fn first_step(&self) -> GitStep<'static> {
return GitStep::Person;
}
/// Settle nothing.
pub fn finish(self, git: GitStatus, _token: Option<&str>, _run_git: &mut GitRunner, _context: &GitContext, _out: &mut dyn Write) -> LadderResult {
return LadderResult { git, carried: None };
}
}
}
#[cfg(not(target_os = "linux"))]
pub use other::{Ladder, LadderResult, begin_ladder};