Skip to main content

Module worktree_copy_selection

Module worktree_copy_selection 

Source
Expand description

The ignored source paths a linked-worktree copy selects, and the path validation every selection passes. What: Which source paths the linked-worktree copy selects: the ignored roots Git reports under the standard exclusion stack, the ignored special entries (sockets, FIFOs, devices) Git’s listing omits, and the validation every repository path passes before it touches the filesystem. Why: Git decides what is ignored; the copy only adds the entries Git’s index-oriented listing cannot report, and it never trusts a path that could leave the worktree.

In TS you’d write (pseudocode):

const roots = await readIgnoredRoots({ sourceRoot, gitPath, excludedRoots });

Enums§

CopySelection
What: Which of a source’s ignored paths one copy takes: every ignored root, or only the named repository paths. Why: A linked or bare source hands over all of its ignored state, as the incumbent does; a main checkout holds the repository’s heavy ignored trees, so it hands over only what the caller names.

Constants§

STAGE_PREFIX
What: The private stage prefix the copy reserves; no selected path may contain a component that starts with it. Why: A selected path that is a private stage would copy the copy into itself.

Functions§

assert_safe_repository_path
What: Validates one slash-separated path that Git reported before it is joined to a filesystem root. Why: An empty, absolute, . or .. component could select a path outside the worktree.
filesystem_path
What: The native path of one validated repository path under a filesystem root. Why: Every filesystem access of the copy goes through this join, so the validation cannot be skipped.
js_order
What: Sorts strings the way JavaScript’s default toSorted does: by UTF-16 code units. Why: Manifest and journal order must match the incumbent’s, which differs from byte order only for supplementary-plane characters.
read_ignored_roots
What: Every existing source path ignored by Git’s standard exclusion stack, as collapsed repository paths. Why: This is the one selection the copy stages, so the same validation and collapse apply everywhere.
read_named_ignored_roots
What: The named repository paths that exist in the source and that Git’s standard exclusion stack ignores. Why: A configured file such as the forbidden-strings rules is copied by name, so the source is never enumerated; a name Git does not list exactly (absent, tracked, not ignored, or a directory) selects nothing, which leaves the destination without it instead of inventing it.
repository_path_within
What: Whether a repository path equals or descends from another repository path. Why: Comparison is by whole components, so cache2 is not inside cache.
select_roots
What: The collapsed repository paths one copy takes from a source under the chosen selection. Why: Staging asks one question whichever source it copies from, so the selection mode is decided in one place.