Skip to main content

Module worktree_add_plan

Module worktree_add_plan 

Source
Expand description

The plan for one git worktree add that the cheap-worktree ladder serves: its destination and insertion point. What: The plan for one git worktree add the cheap-worktree ladder may serve: where the new worktree goes and where in the argument list a rung inserts --no-checkout, or nothing when the invocation uses a form the ladder does not know. Why: The ladder runs real Git once with the person’s arguments, so it only needs the destination path and a promise that every other word means what the table says. An option the table does not list, a bundled short flag, a global option that changes how Git reads configuration, or a destination whose parent does not exist makes the whole invocation a plain Git run, which is always correct.

In TS you’d write (pseudocode):

const plan = parseAddPlan(['-C', 'repo', 'worktree', 'add', '-b', 'topic', '../topic'], 1, cwd); // undefined: plain Git

Structs§

AddPlan
What: The facts of a git worktree add the ladder serves. usize is an unsigned size or index; PathBuf is an owned file-system path. Why: The destination decides the subvolume to create and the worktree to settle; the insertion index decides where --no-checkout goes in the arguments real Git receives.

Functions§

copy_start_directory
What: The directory a command’s relative destination is resolved against, after the global options. Why: Only -C moves it; the others change nothing about it. An option this reading does not know leaves the destination unknown, and the copy then says it did not run.
parse_add_plan
What: Plan one invocation: arguments is the whole argument list, subcommand_index the index of worktree in it, and start the directory the command starts in. Why: The word directly after worktree must be add itself, because Git reads the subcommand there and never abbreviates it.
parse_copy_destination
What: The destination a git worktree add names, in the form Git records it, for every form Git’s option parser accepts. Why: The ignored-state copy goes to the worktree this command created, found from the command line instead of by comparing the repository’s registrations before and after, which another add running at the same time would disturb.
start_directory
What: The directory a command starts in: the process directory moved by every -C <dir> of the global prefix, or nothing when the prefix holds an option the ladder does not serve. Why: Git changes directory at each -C in turn, and a relative destination is relative to the result. A .. component in a -C value is declined, because following it lexically differs from Git’s directory changes through a symbolic link.