Expand description
Setting aside what a snapshot of the main checkout leaves out, and having the commit service empty it.
What:
The leave-out step of a snapshot of the main checkout: set aside the nested worktrees that are ordinary directories,
the other checkouts, the caches and the run records that the main-checkout rule leaves out, into a trash directory inside
the new subvolume, and write down what was made and moved; and, once the worktree is in place, hand the trash to the
commit service as a work item that empties it (worktree_trash_dispose.rs).
Why:
A snapshot carries everything, so the leave-out is a removal. Unlinking about 495 thousand entries takes 14 s, which the
person should not wait for; renaming 480 directories into one trash directory takes 1.6 s, 1.2 s of which is the walk.
The rename keeps the new worktree final at once. The .git pointer of a nested worktree that was copied names another
worktree’s administrative directory, so it is unlinked before anything else and before the add returns. Nothing the
main checkout tracks is ever moved, and every move and removal names one plain entry below a held directory handle.
In TS you’d write (pseudocode):
const { count, trash } = await pruneSnapshot({ stage, source }); // before the swap
await disposePendingTrash({ context, destination, gitDir, trash, notices }); // after itRe-exports§
pub use crate::worktree_trash_dispose::Reach;pub use crate::worktree_trash_dispose::Router;pub use crate::worktree_trash_dispose::TRASH_REFERENCE;pub use crate::worktree_trash_dispose::delete_trash;pub use crate::worktree_trash_dispose::dispose_pending_trash;pub use crate::worktree_trash_dispose::dispose_pending_trash_with;pub use crate::worktree_trash_dispose::empty_trash;pub use crate::worktree_trash_manifest::TrashManifest;pub use crate::worktree_trash_manifest::entry_name;pub use crate::worktree_trash_manifest::is_trash_name;
Structs§
- Pruned
- What the leave-out made and moved, and how many directories it set aside.
Constants§
- MAIN_
SNAPSHOT_ NOTE - The line a snapshot of the main checkout adds to what Git prints, unless
--quietwas given. Why: a snapshot carries the whole ignored state itself, so no copy summary appears; this says what happened instead. - TRASH_
PARENT - The directory, relative to a worktree root, inside which each snapshot’s trash directory is made.
It sits below
.claude/, which the repository ignores, so a trash that has not been emptied yet is no untracked file.
Functions§
- prune_
snapshot - What:
Set aside, inside a fresh snapshot of the main checkout, everything the main-checkout rule leaves out; return how many
directories were set aside and what was made and moved.
Why:
The order matters: what the index tracks is worked out first, and a registered nested worktree that holds or is tracked
content refuses the whole leave-out before anything is touched; then the
.gitpointer of every copied nested worktree and of every other checkout goes, because a Git command run inside such a copy would read and write another worktree’s administrative directory; then the directories move into the trash. A directory above a tracked file, or a tracked gitlink, is never moved, whatever its name. Names are kept as bytes, so a name that is not text is never taken for another. - trash_
location_ is_ ignored - What: Whether Git ignores the place the trash would be made at in this worktree. Why: A trash directory Git does not ignore would list as untracked until emptied, so the leave-out removes in the foreground instead when the answer is no or unknown.