Repository navigation
fix(copy-ignored): give copied files their source's mtime - #4518
Merged
Merged
Conversation
Since #4319 (7c94d69), `wt step copy-ignored` stamps every copied file with one time taken after `git worktree add`. A copied `target/` then looks newer than the sources that checkout just wrote, so cargo reuses artifacts built from other sources: build v1 in main, commit v2 without rebuilding, `wt switch --create feat`, copy-ignored, and `cargo build` finishes in 0.00s with a binary that still prints v1. v0.80.0 on macOS kept source mtimes through clonefile and rebuilt. Each copied regular file now gets its source's mtime, as `cp -a` does, on every platform. That still fixes #4248's Linux case (parallel copies ordering files by scheduling): #4319's own measurements show `cp -a` recompiles the same two units as the stamp. The stamp parameter is gone from `copy_leaf` and `copy_dir_recursive`, so `wt step promote`'s cross-device fallback now keeps mtimes too, like `mv` across filesystems. Symlinks and directories keep the copy time, as in v0.80.0. The integration test copies files with distinct past mtimes, through a directory entry and a top-level entry, and fails on main with the copy-time stamp. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Oct 20, 2026
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since v0.80.0,
wt step copy-ignoredproduces stale cargo builds. #4319 stamps every copied file with one time taken aftergit worktree add, so a copiedtarget/looks newer than the sources that checkout just wrote, and cargo treats it as up to date. Repro: build v1 in main, commit v2 without rebuilding,wt switch --create feat,wt step copy-ignored,cargo build. On main cargo finishes in 0.00s and the binary prints v1; v0.80.0 (which kept source mtimes through clonefile on macOS) recompiles and prints v2.This gives each copied regular file its source's mtime, as
cp -adoes, on every platform, and removes the stamp parameter. That still covers #4248's Linux case, where parallel copies ordered files by scheduling: #4319's own table showscp -arecompiles the same two units as the stamp.wt step promote's cross-device fallback shares the helper, so it now keeps mtimes too, likemvacross filesystems. Symlinks and directories keep the copy time, as in v0.80.0.Verified on macOS: the repro above now recompiles and prints v2, and a tree with 2020-dated ignored files keeps the same mtimes as v0.80.0. The new integration test copies files with distinct past mtimes through a directory entry and a top-level entry; it fails on main and passes here. The read-only unit test now asserts the source mtime.
Not covered, on v0.80.0 either: copying into an existing worktree whose sources were checked out before the source worktree's build still leaves outputs newer than those sources, so cargo reuses them.