Skip to content

fix(copy-ignored): give copied files their source's mtime - #4518

Merged
max-sixty merged 1 commit into
mainfrom
fix/copy-ignored-mtime
Oct 20, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/copy-ignored-mtime

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Since v0.80.0, wt step copy-ignored produces stale cargo builds. #4319 stamps every copied file with one time taken after git worktree add, so a copied target/ 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 -a does, 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 shows cp -a recompiles the same two units as the stamp. wt step promote's cross-device fallback shares the helper, so it now keeps mtimes too, like mv across 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.

This was written by Claude Code on behalf of max-sixty

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]>
@max-sixty
max-sixty merged commit 7d59f69 into main Oct 20, 2026
38 checks passed
@max-sixty
max-sixty deleted the fix/copy-ignored-mtime branch October 20, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants