Run xtask in the invoking Cargo worktree #3591

Open
github-bot wants to merge 1 commit from github-bot/gh-3591 into main AGit
Owner

@⁠Yoshi-233 on GitHub · 2026-11-30 01:24 UTC · original
Yoshi-233:fix/xtask-worktree-root → main · +8 −0 · 1 files · 1 commits · open

What it changes

Use the manifest directory Cargo supplies at invocation to choose the checkout for cargo xtask. When multiple worktrees share a target directory, Cargo can reuse the same executable. Its compile-time manifest directory then points at the checkout where it was built. The old code could report the staged-file count from a different worktree.

The runtime path is used when its parent has the repository marker. Direct execution without Cargo's manifest environment keeps the existing fallback.

How it was tested

  • Created two detached worktrees at the same commit and staged one harmless Markdown file in A and two in B. Used the same CARGO_TARGET_DIR for both and ran cargo xtask policy --staged in A and then B. Main reported 1 and 1. The patched tool reported 1 and 2. No rule or list of accepted files was changed.
  • Invoked the patched tool from outside either tree with Cargo's --manifest-path pointing at B: it reported 2. All-targets Cargo check and strict Clippy passed on Linux.
  • The xtask suite had six passes and one failure on both main and the patch: the existing full-tree policy test flags the same file, crates/victory-loader/src/heap_sites/frame_users.rs. The staged-file policy check passed for this PR.

Windows CI stopped in the first Clippy step on the unchanged crash.rs:804 unused-function diagnostic for unwind_copy. The test step did not run. PR check · Same main commit

Checked for overlap

  • Searched for worktree/xtask PRs and reviewed other open changes to the entry point. #1294 changes test-gate commands.
**@⁠Yoshi-233** on GitHub · 2026-11-30 01:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3591) `Yoshi-233:fix/xtask-worktree-root` → `main` · +8 −0 · 1 files · 1 commits · open ## What it changes Use the manifest directory Cargo supplies at invocation to choose the checkout for `cargo xtask`. When multiple worktrees share a target directory, Cargo can reuse the same executable. Its compile-time manifest directory then points at the checkout where it was built. The old code could report the staged-file count from a different worktree. The runtime path is used when its parent has the repository marker. Direct execution without Cargo's manifest environment keeps the existing fallback. ## How it was tested - Created two detached worktrees at the same commit and staged one harmless Markdown file in A and two in B. Used the same `CARGO_TARGET_DIR` for both and ran `cargo xtask policy --staged` in A and then B. Main reported 1 and 1. The patched tool reported 1 and 2. No rule or list of accepted files was changed. - Invoked the patched tool from outside either tree with Cargo's `--manifest-path` pointing at B: it reported 2. All-targets Cargo check and strict Clippy passed on Linux. - The xtask suite had six passes and one failure on both main and the patch: the existing full-tree policy test flags the same file, `crates/victory-loader/src/heap_sites/frame_users.rs`. The staged-file policy check passed for this PR. Windows CI stopped in the first Clippy step on the unchanged `crash.rs:804` unused-function diagnostic for `unwind_copy`. The test step did not run. [PR check](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46334752408/job/141572402165) · [Same main commit](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46320380085) ## Checked for overlap - [x] Searched for worktree/xtask PRs and reviewed other open changes to the entry point. #1294 changes test-gate commands.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 01:26:18 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 17:20 UTC · original

Checked on Windows 11 with Cargo 1.98.1 (pinned), on main (84bd61e2); cherry-picks cleanly. This matters more than a wrong count: on main, the pre-commit check can let a refused file through.

Two git worktrees of the same commit share one CARGO_TARGET_DIR. In the second worktree only, a file named zz-probe.png (plain text, a probe) is staged. Then cargo xtask policy --staged runs in each, in the order shown:

first run second run
main, clean worktree first clean: 0 files ok with the .png staged: 0 files ok, exit 0
main, .png worktree first with the .png: refused clean: refused for the other worktree's .png
this PR, clean worktree first clean: 0 files ok with the .png: refused, exit 1
this PR, .png worktree first with the .png: refused clean: 0 files ok

So on main, whichever worktree builds xtask first is the one every later run checks, which is the same reuse #3799 fixes in victory-shader's build script. With this PR, each run checks its own worktree. Clippy on xtask is clean with -D warnings.

cargo test -p xtask: 6 passed, 1 failed, repository_passes_policy, the same on main. On 84bd61e2 the file it flags is no longer frame_users.rs but crates/victory-shader/src/native.rs:1720, a 560-character hex string in loose_metadata_reads_version_0x403 (added in 698ab79e).

**@⁠babuakhil** on GitHub · 2026-11-30 17:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3591#issuecomment-7286108117) Checked on Windows 11 with Cargo 1.98.1 (pinned), on `main` (`84bd61e2`); cherry-picks cleanly. This matters more than a wrong count: on `main`, the pre-commit check can let a refused file through. Two git worktrees of the same commit share one `CARGO_TARGET_DIR`. In the second worktree only, a file named `zz-probe.png` (plain text, a probe) is staged. Then `cargo xtask policy --staged` runs in each, in the order shown: | | first run | second run | |---|---|---| | `main`, clean worktree first | clean: `0 files ok` | **with the `.png` staged: `0 files ok`, exit 0** | | `main`, `.png` worktree first | with the `.png`: refused | **clean: refused for the other worktree's `.png`** | | this PR, clean worktree first | clean: `0 files ok` | with the `.png`: refused, exit 1 | | this PR, `.png` worktree first | with the `.png`: refused | clean: `0 files ok` | So on `main`, whichever worktree builds xtask first is the one every later run checks, which is the same reuse #3799 fixes in `victory-shader`'s build script. With this PR, each run checks its own worktree. Clippy on `xtask` is clean with `-D warnings`. `cargo test -p xtask`: 6 passed, 1 failed, `repository_passes_policy`, the same on `main`. On `84bd61e2` the file it flags is no longer `frame_users.rs` but `crates/victory-shader/src/native.rs:1720`, a 560-character hex string in `loose_metadata_reads_version_0x403` (added in 698ab79e).
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-12-01 01:58 UTC · original

Thanks for testing both worktree orders on Windows. The clean-first case shows the impact especially clearly: the old check let the staged .png through. It’s good to have independent confirmation that the fix checks the right worktree in both orders.

**@⁠Yoshi-233** on GitHub · 2026-12-01 01:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3591#issuecomment-7298103689) Thanks for testing both worktree orders on Windows. The clean-first case shows the impact especially clearly: the old check let the staged `.png` through. It’s good to have independent confirmation that the fix checks the right worktree in both orders.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3591/head:github-bot/gh-3591'
git switch 'github-bot/gh-3591'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3591'
git switch 'github-bot/gh-3591'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3591'
git switch 'github-bot/gh-3591'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3591'
git switch 'main'
git merge --squash 'github-bot/gh-3591'
git switch 'main'
git merge --ff-only 'github-bot/gh-3591'
git switch 'main'
git merge 'github-bot/gh-3591'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3591
No description provided.