Skip to main content

Module policy_added_path

Module policy_added_path 

Source
Expand description

Whether a direct fix may change a tracked file it did not select. What: Whether a direct fix may change a tracked file it did not select, and the patch-conflict message when it may not. Why: SPEC.md (“Added paths”) admits such a file only when HEAD, the real index, the private index and the worktree all hold the blob the correction was computed against, so the fix discards nobody’s change. The reasons and the remedy are the installed wrapper’s words (commit-transaction-added-paths.ts, assertAddablePath and its direct-fix message), checked in its order.

In TS you’d write (pseudocode):

// await assertAddablePath({ ..., path, oid, lifecycle: 'direct-fix' }); // throws AddedPathPreconditionError

Constants§

ADDED_PATH_HEAD_REASON
The reason HEAD does not hold the file the correction was computed against.
ADDED_PATH_MISSING_REASON
The reason the worktree has no copy of the file.
ADDED_PATH_STAGED_REASON
The reason the index holds a different entry than HEAD.
ADDED_PATH_UNSTAGED_REASON
The reason the worktree copy differs from HEAD.

Functions§

added_path_message
What: The direct-fix patch-conflict message for a file and a reason. Why: It names both ways out: select the file, or restore it to HEAD.
head_mode
What: HEAD’s mode for the file, or why HEAD and the index rule it out. index is the private index’s entry, whose object the correction was computed against; for a file the fix did not select it equals the real index’s entry. Why: HEAD must hold the same object as an ordinary file; the index must then hold it with HEAD’s mode. The mode is what the worktree copy is checked against next.
worktree_refusal
What: Why the worktree copy rules out the file, if it does. Err is a read the system refused for another reason than the file being absent. Why: The copy must be a plain file, not a link, with HEAD’s executable bit and bytes.

Type Aliases§

Entry
What: An index or tree entry: its mode and object. Why: Entries are compared field by field, as the installed wrapper compares mode text and object names.