Skip to main content

Module worktree_convert

Module worktree_convert 

Source
Expand description

Converting a linked worktree that is an ordinary directory into a btrfs subvolume at the same path, resumably. What: Convert one registered linked worktree that is an ordinary directory into a btrfs subvolume at the same path, resumably: quiesce it, copy it with cloned data into <path>.cli-git-converting, prove the copy equals the original, swap the two with one atomic exchange, refresh the index stat fields, and remove the old tree only after the swap is verified. Why: A snapshot of the main checkout shows a nested worktree that is a subvolume as an empty directory, and one that is an ordinary directory as a full copy that must then be removed (0.5 s each). Converting each ordinary worktree once makes every later snapshot skip it for nothing. The registration is untouched: the path and the bytes of the .git file do not change, so the administrative directory’s back-pointer stays valid. A journal in the administrative directory records the phase, so a rerun completes the conversion in place; nothing is deleted that the journal does not prove this command created.

In TS you’d write (pseudocode):

const verdict = await convertWorktree({ platform, path, options, interrupt, say });

Re-exports§

pub use crate::worktree_convert_journal::JOURNAL_NAME;
pub use crate::worktree_convert_journal::Phase;

Structs§

Candidate
What: The facts about a worktree path that every mode needs. Why: They are read once, from the .git file and the administrative directory, without starting Git.
ConvertOptions
What: What the command asks of one worktree. Why: The dry run and the abandon are modes of the same pass over the same facts.
Owned
What an interrupted conversion of this command owns at this moment, established by identity before the refusals are made.
Refusal
One reason a worktree cannot be converted now: its kind and the sentence for the person.

Enums§

RefusalKind
What kind of reason stands in the way, so a caller exempts what it owns by kind and identity, never by the words.
Verdict
What: What a run did with one worktree. Why: The command prints one line per worktree and maps the verdicts to its exit status.

Constants§

CONVERTING_SUFFIX
The suffix of the sibling subvolume the copy is built in.

Functions§

convert_worktree
What: Convert, resume, abandon or preview one worktree. Why: One function holds the phase order, so the controls exercise the real sequence; the platform and the interrupt are injected so the controls run it on any filesystem and kill it at every phase. A real run holds the conversion lock from before it reads the journal until it ends.
converting_path
The sibling path the copy is built at.
inspect
What: Read the registration of a worktree path: its .git file, its administrative directory, and the back-pointer. Why: Only a linked worktree whose administrative directory names this very path back is converted; anything else (the main checkout, a submodule, a stale registration) is refused with the reason.
refusals
What: Every reason a worktree cannot be converted now, with its kind; empty means it can. Why: The dry run prints them all, and a real run refuses on the first call with the whole list. The registrations are read from the common directory itself, so a bare layout is checked like any other.