mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
The same directory reaches this process under three names on Windows and only two of them compare equal. A pane and the OS say `C:\Users\x\repo`; Git for Windows is MSYS2, so `rev-parse --show-toplevel` and `--git-common-dir` say `C:/Users/x/repo` whatever shell asked; and `fs::canonicalize`, which is what `Host::canonicalize` was, says `\\?\C:\Users\x\repo`. `Path` forgives the first two of each other — it compares, hashes and prefix-matches by component, and both separators end one, which also covers a UNC share, a `\\wsl$` path and a `subst` drive. It does not forgive the third: `\\?\C:` parses as `Prefix::VerbatimDisk` where `C:` is `Prefix::Disk`, so it matches neither, by equality, by hash or by `starts_with`. Every cache in the SCM layer is keyed by exactly that comparison, so a root that came in past `canonicalize` and a root that came out of `git` name one repository and share nothing. `core::path_spelling` settles it once, at the boundary each path is created at rather than at each of the places one is later compared: `git_path` for everything `rev-parse` prints, and `LocalHost:: canonicalize` on its way out — `\\?\` is a Win32 API escape hatch, not part of a path's identity, and what the call is *for* (a junction, a `subst` drive, an 8.3 name, a symlink) is untouched. `GitStatusCache`, where a repository actually gets its identity, insists on it for its own keys too, so a caller that resolves a path cannot re-open the gap. The spelling landed on is the plain one, which is also what `ParseDisplayName` takes and the only one a person recognises in a tooltip; `ui::path_display::native_separators` now delegates its half of the rule rather than restating it in the other crate. What this is and is not. Traced through every production route by which a `\\?\` path could become a repo key: it cannot become a *pane cwd*, which is what keys `GitStatusCache` and reaches `overlay.cwd`. The kernel cwd probe is a `None` stub off macOS and Linux, so on Windows the cwd comes only from OSC 7 or the agent hook stream and neither resolves; the CLI refuses to canonicalize on purpose; restore, window state and the sidebar never do. So the diff overlay's re-read loop, and the panel and commit detail failing to recognise their own repository, are reachable today only where something resolves a path first — which in this tree is the tests. A separate CPU measurement on a real GUI agrees: zero `git.exe` spawns, idle or loaded, overlay open or closed. The one production route that does resolve and does reach a repo key is `editor_open_on_host`, which stores the canonicalized path as `OpenFile::path`; `scm_editor_target` then looks its parent up in `GitStatusCache` and misses, so on Windows a focused editor never subscribed to its repository's `.git` watch. That is a missing subscription rather than extra work: with the panel or the file tree also on screen their watch covers it, and alone it leaves the SCM data stale until something else asks. The rest of the value is the invariant and the tests. The caches were one resolved path away from splitting a repository in two at any of four surfaces, with no test anywhere holding them to a single spelling. Also worth naming, because the gate this was found behind blamed the wrong half: stripping `\\?\` *is* the fix, and slash direction is not what breaks a `PathBuf` — `path_equality_already_forgives_case_slashes_ and_a_trailing_separator` pins that, so a later change here cannot quietly start folding what `Path` already folds, or stop folding what it does not. The tests are ungated, deliberately. Windows is the only platform with three spellings and was the only one not running the comparison, which is how this lived; a `#[cfg(unix)]` on any of them would put it back. Where one needs a repository it runs `git init` in a temp directory rather than reading the checkout it is in. Found while un-gating the window and pane tests in #791, which left `scm::detail::detail_gpui_tests`, `scm::panel::a_settled_source_control_ panel_reaches_render_idle` and `diff_overlay::render_idle_gpui_tests` gated on this divergence.