Expand description
The four top-level spellings after which the wrapper announces itself,
and the text it prints once Git has answered.
What:
Recognize the four top-level spellings after which the wrapper says it is not plain Git
(--version, -v, --help, -h),
and build the text it prints once Git has answered.
Why:
A caller who types git --version should be able to tell that a policy wrapper sits in front of Git,
without the wrapper changing a single byte of what Git itself printed.
Every other query (--exec-path, --html-path, …) stays an exact process replacement.
In TS you’d write (pseudocode):
// const query = announcedQuery(args, globalLayout(args));
// after the child exits: if (outcome === { exited: 0 }) process.stdout.write(announcement(query, version, realGit));Enums§
- Announced
Query - Which announced query an invocation is.
Constants§
- WRAPPER_
VERSION - What:
The crate version printed in the banner.
env!reads a Cargo-provided environment variable while compiling. Why: The banner must name the wrapper build that answered, and the manifest is the one place that version lives.
Functions§
- announced_
query - What:
Say whether the query token of an invocation is one of the four announced spellings.
Option<AnnouncedQuery>is “the query, or nothing”. Why: The layout already told the caller this is a query and where it sits; only the exact token separates--versionfrom--exec-path. Nothing else is read, so commands that are not queries pay one comparison. - announcement
- What:
Build the text printed after Git’s own answer.
&strborrows the version;&Pathborrows the resolved real Git path; the result is owned, line-terminated text. Why: The banner states which wrapper build and which Git answered; the help section also says what the wrapper adds. Building it from plain values keeps it testable without a process. A path that is not UTF-8 prints with replacement characters, because the text is for people. - printable_
after - What:
The part of the announcement to print for a finished child.
The result borrows from
text. Why: Git that failed or was killed did not answer, so the caller sees Git’s status and Git’s own diagnostics unchanged.