Expand description
Repository and worktree identity as reported by real Git.
What:
Ask real Git which repository and worktree an invocation selects.
Why:
Configuration lives at the worktree top level,
and worktree policies need to
know main versus linked.
Git applies -C,
--git-dir,
--work-tree and its
environment itself,
so the wrapper never re-implements that selection.
In TS you’d write (pseudocode):
// const identity = await resolveGitWorktreeIdentity({ args, gitPath });Enums§
- Worktree
Identity - What:
The repository shape an invocation selects.
#[derive(...)]generates cloning, debug printing and==. Why: Each shape needs different handling: no repository means no configuration, a bare repository has no worktree, and main versus linked decides worktree policies. All paths are Git’s own canonical absolute paths.
Constants§
- IDENTITY_
QUERY - What:
The
rev-parseoptions of the identity query, in output order.&[&str]is a borrowed list of borrowed strings compiled into the program. Why: One query answers everything.--show-toplevelis last because Git stops there in a bare repository after already printing the first three lines.
Functions§
- parse_
identity_ output - What:
Interpret the identity query’s exit state and output.
std::io::Result<T>isResult<T, std::io::Error>. Why: Success prints four lines. Failure after three lines is a repository without a worktree (bare when the first line says so). Failure with no output is “not a repository”. Any other shape is rejected rather than guessed. - resolve_
worktree_ identity - What:
Resolve the identity selected by the caller’s global Git options.
&[OsString]borrows the arguments before the subcommand, unchanged. Why: Replaying the complete global prefix lets Git apply-Cchains through symbolic links,--git-dir,--work-treeand environment selection exactly as it will for the forwarded command. - worktree_
root - What:
The worktree top level of an identity,
when it has one.
Option<&Path>is “a borrowed path or nothing”. Why: Configuration is loaded only for main and linked worktrees.