Summary
After rewriteFile renames the temp file over the target, the modification time becomes "now". For files whose contents didn't actually change (e.g., find string occurs but no replacement happens — handled — or replacement happens but produces identical bytes — possible with overlapping find/replace) we already skip the rename. But for files that DO change, the mtime jumps forward.
This invalidates Make-style timestamp dependency tracking, file-watcher caches, and various reproducible-build setups that rely on mtime stability. Some users explicitly run find-replace as part of code generation pipelines that depend on stable mtimes.
Impact (Reliability: Low)
- Surprises some workflows.
git status is unaffected (git uses content), so most users won't notice.
Suggested Fix
After the temp file is fully written but before the rename, os.Chtimes(tmpName, info.ModTime(), info.ModTime()) (atime is harder to preserve and rarely matters; could use the original atime too).
This is consistent with what sed -i and perl -i users expect.
Files
file_handling.go:60-149 (rewriteFile)
Summary
After
rewriteFilerenames the temp file over the target, the modification time becomes "now". For files whose contents didn't actually change (e.g., find string occurs but no replacement happens — handled — or replacement happens but produces identical bytes — possible with overlapping find/replace) we already skip the rename. But for files that DO change, the mtime jumps forward.This invalidates Make-style timestamp dependency tracking, file-watcher caches, and various reproducible-build setups that rely on mtime stability. Some users explicitly run find-replace as part of code generation pipelines that depend on stable mtimes.
Impact (Reliability: Low)
git statusis unaffected (git uses content), so most users won't notice.Suggested Fix
After the temp file is fully written but before the rename,
os.Chtimes(tmpName, info.ModTime(), info.ModTime())(atime is harder to preserve and rarely matters; could use the original atime too).This is consistent with what
sed -iandperl -iusers expect.Files
file_handling.go:60-149(rewriteFile)