Repository navigation
Conversation
…ript The build script watched <root>/.git/index and <root>/.git/HEAD. In a worktree .git is a file, so neither exists, and Cargo reruns a script whose watched path is missing on every build, recompiling the crate and relinking its worker binary each time. Ask git for each control file's path (HEAD, the index, packed-refs, the current branch's ref) and watch only files that exist.
|
Recommendation: revise. The worktree rebuild loop is real, and this script is the right place to stop it. One ref update still leaves Why
In a linked worktree, The same What and howThe script asks git for each control path ( That filter is required. A missing path brings the rebuild loop back. What I measuredToolchain: cargo 1.97.1, git 2.43.0. Merge base GQT cannot express a build-script fingerprint. I did not run the corpus. I ran A linked worktree of this repository at the PR commit, with the PR
The merge-base script in that same worktree: checks 2 and 3 were dirty with A plain clone ( Also confirmed with the same bytes:
BlockingAfter
I ran that directory fallback on the same While the directory is the watch, another ref in that directory also causes a rebuild. That is one extra rebuild. The following build watches the single file. Bench already accepts that cost. It is cheaper than a false commit id, and it does not restore the every-build loop. Optional
Keep one rule for "which git files invalidate a baked commit." Bench and this script already disagree. A third copy will disagree again. Put the directory rule in this file now. Move A test that reads the build-script output and asserts every LiabilityThe change removes a rebuild that does not depend on source edits, in every layout where It adds a second git-watch policy. That policy is silent when the branch ref is packed and the next update creates the loose file without touching the index. Five more build scripts of this shape would be five path lists. The durable owner is the bench rule: an existing file, or the nearest existing directory for a branch ref, never a missing path, never the whole git dir. AlignmentPRs 1174, 1176, 1177, and 1178 do not touch this script. PR 1153 packages the workspace with naersk and LimitationsI did not link the 350 MB GQT worker and I did not run the GQT corpus. In the omnigraph worktree, the package manifest was reduced to this build script and an empty library so Cargo did not compile the engine. The script bytes were the PR blob. Cargo's fingerprint is the behavior under test. The plain-clone and ref-update runs used those same bytes in small git repositories, not the full engine crate. Inline comment on The
Reproduced on cargo 1.97.1 with this script: after
While the directory is the watch, a change to another ref in that directory also rebuilds. That cost is one extra rebuild, then the script watches the single file again. |
In a git worktree,
omnigraph-gqt's build script reran on every build. It watched<root>/.git/indexand<root>/.git/HEAD, but in a worktree.gitis a file, so neither path exists, and Cargo treats a missingrerun-if-changedpath as changed on every build. Eachcargo test -p omnigraph-gqtthen recompiled the crate and relinked its 350 MB worker binary. On macOS the first launch of a newly linked binary waits while XProtect scans it, so local GQT cases failed preflight against their 10-second budget, including cases unrelated to the change under test.The build script now asks git for each control file's path (
git rev-parse --git-path, joined to the repository root when git prints it relative): HEAD, the index,packed-refs, and the ref HEAD names when it is on a branch. It watches only files that exist. In a worktree these resolve to the worktree's private HEAD and index and to the common directory's refs. A plain clone gets the same two files as before plus the branch ref andpacked-refs, so a commit that leaves the index unchanged also refreshesGQT_SOURCE_REVISION.omnigraph-bench/build.rsalready resolves the git directory the same way, and no other build script watches git files.Measured in a worktree with
cargo check -p omnigraph-gqt --tests --lockedafter a first full check. With the old script, each of two further runs compiledomnigraph-gqtagain. With this one, both compiled nothing; the second of the original pair finished in 1.16 s.