Repository navigation
Conversation
…d statusline `wt list --full` and `wt statusline` now count untracked-file lines in the `HEAD±` working-diff segment, matching what `wt step diff` shows. Default `wt list` and the picker stay on the cheap `git diff --shortstat HEAD` path (tracked-only) — the untracked-inclusive variant joins `BranchDiff` / `CiStatus` / `SummaryGenerate` in the same "expensive bucket" the `--full` flag opens up, so the explanation is "`--full` includes untracked too" with no new exception. A new `WorkingTree::temp_index()` returning a `TempIndex` helper consolidates the index-copy-and-stage trick previously open-coded in `wt step diff`, `WorkingTreeConflictsTask`, and the new `working_tree_diff_stats_with_untracked` method. `TempIndex::git()` returns a `Cmd` already wired with `current_dir`, log context, and `GIT_INDEX_FILE` — three call sites collapse to a few lines each, and the real index is never mutated. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
All six modified snapshots now embed a hardcoded macOS path:
LLVM_PROFILE_FILE: /var/folders/v3/8k5q0_6j3_q6gl4h8czr66sh0000gn/T/wt-test-profraw/cov-%m_%p.profraw
These tests will fail on Linux/Windows CI runners (where std::env::temp_dir() resolves to e.g. /tmp) and on any other macOS machine. None of the previously-existing --full snapshots have this line — it was introduced by re-accepting these snapshots in a coverage-flavored environment after #2730.
Root cause is in tests/common/mod.rs:1098-1100 — the filter intended to strip these vars only matches quoted YAML scalars:
settings.add_filter(r#" CARGO_LLVM_COV: "1"\n"#, "");
settings.add_filter(r#" CARGO_LLVM_COV_TARGET_DIR: "[^"]+"\n"#, "");
settings.add_filter(r#" LLVM_PROFILE_FILE: "[^"]+"\n"#, "");serde_yaml emits paths like /var/folders/.../cov-%m_%p.profraw (and /tmp/wt-test-profraw/cov-%m_%p.profraw on Linux) as plain scalars, so the "[^"]+" group never matches and the value leaks into the snapshot. This is a latent bug from #2730 that any first regeneration after that PR would surface.
Suggested fix — relax the filters to match either form, then regenerate the six affected snapshots:
settings.add_filter(r#" CARGO_LLVM_COV: .+\n"#, "");
settings.add_filter(r#" CARGO_LLVM_COV_TARGET_DIR: .+\n"#, "");
settings.add_filter(r#" LLVM_PROFILE_FILE: .+\n"#, "");Happy to push a fix commit (filter relaxation + regenerated snapshots) if you'd like — say the word.
The core refactor (TempIndex consolidating three call sites, gating the untracked-inclusive path behind working_tree_status.untracked) and the new unit test that checks the real index stays byte-identical look good to me.
Snapshots regenerated in this branch leaked `LLVM_PROFILE_FILE: /var/folders/.../wt-test-profraw/cov-%m_%p.profraw` into the env block — `isolate_subprocess_env` (#2730) sets the var on every test subprocess, and `insta_cmd` records it verbatim with a platform-specific path. The intended scrub at `setup_snapshot_settings` was never effective: `add_filter` substitutes only on captured snapshot content, not the YAML info/env block where env entries live, so the regex wasn't matching anything. Switch to `add_redaction(".env.LLVM_PROFILE_FILE", ...)` (and the same for `CARGO_LLVM_COV*`) inside `add_standard_env_redactions`, which is already bound by the `repo` rstest fixture for every test that uses it. Drop the obsolete `add_filter` lines and regenerate the six affected snapshots — values now read as stable `[LLVM_PROFILE_FILE]` placeholders matching the convention used for HOME, GIT_CONFIG_GLOBAL, etc. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
macOS test failure looks unrelated to this PR — run · |
…#2768) The `tests/CLAUDE.md` "Snapshot env drift is cosmetic" rule was too broad. It correctly covers stable values (`""`, `C`, redacted placeholders) but also waved through host-specific leaks. While regenerating snapshots in #2764, a macOS `LLVM_PROFILE_FILE` tempdir path leaked into the env block and the "cosmetic" framing nearly let it pass review. This splits the section into two cases: stable values stay accept-silently; host/temp/PID/timestamp values are leaks that must be redacted via `add_redaction(".env.VAR", "[VAR]")` in `add_standard_env_redactions`. It also records the non-obvious gotcha that `add_filter` never touches the `env:` block (it only substitutes on captured snapshot content) — the actual fix mechanism applied in #2764. Docs-only; no code or test changes. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
… row count (#2767) The `expected_rows: Some(1)` gate (added in #2729) waits for skim's row list to filter down after the test types its query. But skim's matcher runs on a separate thread, and under heavy parallel macOS load the row redraw can lag the matcher by more than the 30s timeout — even though skim's selection cursor and preview pane have already advanced to the matched item. The gate then panics with `saw 2`, while the test would have selected the right item anyway: Enter acts on the cursor, not on which rows happen to be painted. This is the flake reported on `test_switch_picker_no_cd_prints_branch_without_switching` (local) and `test_switch_picker_switch_to_existing_worktree` (CI on #2764). These three `target`-selection tests don't snapshot the list panel, so they don't need the filter applied — only the cursor on the right item. They now gate on the preview-pane text that's emitted once skim's selection moves to target-branch, which tracks the cursor rather than the lagging redraw. If selection genuinely never moves, the content gate still fails loudly, so the diagnostic value of #2729 is preserved. Reproduced the original flake at ~2/5 with 5 parallel `cargo test test_switch_picker -- --test-threads=20`. After the fix: 0 occurrences of the line-528 panic across 48-run focused stress, the original 5×20 recipe, and a 16× pathological run. The `preview_panel_*` snapshot tests share the same matcher-lag root cause but genuinely need the filter applied (they snapshot the list); they weren't in scope here and remain as follow-up. Also deletes `test_switch_picker_no_cd_suppresses_directive` — a strict subset of `test_switch_picker_no_cd_prints_branch_without_switching` (identical setup/env/inputs, both assert exit 0 + empty cd file; the latter additionally asserts the printed branch name). Same belief, no coverage lost. Net diff is a reduction. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
wt list --fullandwt statuslinenow count untracked-file lines in theHEAD±working-diff segment, matching whatwt step diffshows. Defaultwt listand the picker stay on the cheapgit diff --shortstat HEADpath (tracked-only). Putting the untracked-inclusive variant behind the same--fullboundary asBranchDiff/CiStatus/SummaryGeneratemeans the explanation stays simple — "--fullincludes untracked too" — with no new exception class.Mechanism
WorkingTree::working_tree_diff_stats_with_untracked()registers untracked files in a temporary copy of the index viagit add --intent-to-add ., then runsgit diff --shortstat HEADagainst that temp index. Same trickwt step diffuses; the worktree's real index is never touched (a unit test diffs the index bytes before/after to lock that contract in).WorkingTreeDiffTaskbranches on the new flag and on the cached porcelain — when no untracked entries exist, the expensive path is skipped (the two paths are bit-equivalent for tracked-only worktrees).Refactor
A new
TempIndexhelper consolidates the "copy index + stage stuff into it + run a follow-up git command" pattern that was previously open-coded in three places (wt step diff,WorkingTreeConflictsTask::write_tree_with_working_tree, and the new method above).TempIndex::git(args)returns aCmdalready wired withcurrent_dir, log context, andGIT_INDEX_FILE, so each caller collapses to a few lines.Wiring
A new
include_untracked_in_working_diff: boolonCollectOptionsflows throughTaskContexttoWorkingTreeDiffTask. Set fromshow_fullincollect/mod.rs, hard-codedtrueinstatusline.rs, hard-codedfalsefor the picker (the only otherShowConfig::Resolvedconsumer, which intentionally runs the same fast bucket as defaultwt list).Snapshot env scrub fix (second commit)
A pre-existing latent bug surfaced when regenerating the six
--full/ statusline snapshots:LLVM_PROFILE_FILE(set on every test subprocess byisolate_subprocess_envsince #2730) leaked into the env block as a platform-specific tempdir path. The intended scrub atsetup_snapshot_settingswas usingadd_filter, which only substitutes on captured snapshot content — never on the YAML info/env block — so it was dead code. Replaced withadd_redaction(".env.LLVM_PROFILE_FILE", ...)(and the same forCARGO_LLVM_COV*) insideadd_standard_env_redactions, which is already bound by thereporstest fixture; values now render as stable[LLVM_PROFILE_FILE]placeholders matching the existing convention for HOME / GIT_CONFIG_GLOBAL / etc.Tests
3695 pass: one new unit test for
working_tree_diff_stats_with_untracked(verifies untracked lines counted, real index byte-identical), plus snapshot updates for nine--full/ statusline tests where untracked files now contribute toHEAD±.