Commit 8ae3b8d
committed
fix(tooling): isolate git children from ambient GIT_* and make a shared core.bare flip loud
A gate self-test that shells out to `git` inherited the repository location a
hook exports (`GIT_DIR` / `GIT_WORK_TREE` / `GIT_INDEX_FILE`), which outranks
`cwd`: its `git add -A` staged 8,190 paths as deleted in the real index and its
`git init` wrote `core.bare = true` into the SHARED `.git/config`, breaking the
primary checkout for every agent on the box. Every case still printed `ok`.
- scripts/git-env.mjs: the class rule in one place. `gitFreeEnv()` for a git
child that must stay inside its own `cwd`, `withoutGitEnv()` for a call one
frame down that passes no environment of its own, and the boundary stated
where it can be read: never strip for a child that fetches or pushes, because
GIT_CONFIG_* and GIT_SSL_* carry the transport configuration. Its self-test
reproduces the leak against real git (red) before proving the strip (green).
- scripts/symbol-anchors.mjs: `trackedFiles` passes an explicit stripped
environment, so a sweep of a synthetic root can no longer answer with the real
repository's file list. Pinned by a self-test case that injects a bogus
GIT_DIR and requires the sweep to resolve its own tree; before the change that
case threw.
- The two corpus gates built on that resolver build their fixture repositories
the same way, so both spawn stripped too.
- scripts/check-system-context-census.mjs drops its local copy of the strip and
imports the shared one; its regression pin is unchanged.
- scripts/setup-git-hooks.mjs carries the tripwire. In the flipped state no
commit is possible, so no hook can be the alarm; `pnpm install` is the first
thing that runs after the damage. It warns there and refuses under
`--self-test`. Measured: `rev-parse --is-inside-work-tree` prints `false` and
exits 0 under the flip, so the predicate reads `core.bare` on the shared
common dir, which is also the only reading a linked worktree can take.
Refs #16624
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW81 parent 8341ed2 commit 8ae3b8d
7 files changed
Lines changed: 607 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
242 | | - | |
243 | | - | |
244 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
245 | 252 | | |
246 | 253 | | |
247 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
365 | | - | |
366 | | - | |
367 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
368 | 375 | | |
369 | 376 | | |
370 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
| |||
1688 | 1689 | | |
1689 | 1690 | | |
1690 | 1691 | | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
1691 | 1697 | | |
1692 | 1698 | | |
1693 | 1699 | | |
1694 | | - | |
1695 | | - | |
1696 | | - | |
1697 | | - | |
1698 | | - | |
1699 | | - | |
1700 | 1700 | | |
1701 | 1701 | | |
1702 | 1702 | | |
| |||
0 commit comments