Repository navigation
find: -newerXt matches only strictly newer files, and keeps the sign of pre-1970 times - #914
Conversation
…of pre-1970 times
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #914 +/- ##
==========================================
+ Coverage 92.57% 92.59% +0.01%
==========================================
Files 37 37
Lines 7746 7766 +20
Branches 393 394 +1
==========================================
+ Hits 7171 7191 +20
Misses 435 435
Partials 140 140 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing |
| let reference = if self.time >= 0 { | ||
| UNIX_EPOCH + Duration::from_millis(self.time.unsigned_abs()) | ||
| } else { | ||
| UNIX_EPOCH - Duration::from_millis(self.time.unsigned_abs()) |
There was a problem hiding this comment.
this can still panic for extreme dates, e.g. before 1601 on Windows
could you please use checked_add / checked_sub?
There was a problem hiding this comment.
Done in 20a67ee. The reference is now built with checked_add / checked_sub. If it can't be represented, a reference before 1970 counts every file as newer and one after counts none. The test now also covers i64::MIN and i64::MAX.
| UNIX_EPOCH - Duration::from_millis(self.time.unsigned_abs()) | ||
| }; | ||
| // Strictly newer, like GNU find | ||
| Ok(this_time > reference) |
There was a problem hiding this comment.
did you run the bfs / GNU testsuite on this? e.g.
bash util/build-bfs.sh gnu/newermt
bash util/build-gnu.sh (GNU source cloned from https://git.savannah.gnu.org/git/findutils.git into ../findutils.gnu)
There was a problem hiding this comment.
Yes, on main (e176572) and on this branch:
- bfs
--gnu: 284 pass, 35 fail, 19 skip - GNU findutils 4.10.0 testsuite: 426 pass, 74 fail, 2 skip
Every test has the same result on both. common/newermt, common/newermt_epoch_minus_one and tests/find/newer fail on both before they reach this code: the date parser rejects 1991-12-14T00:01, 1969-12-31T23:59:59Z and 2026-10-22 16:30:21.985325805 +0530.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for your PR |
NewerTimeMatchercomparesreference <= file timein milliseconds, so a file whose time equals the reference matches, and it takes the absolute value of a time before 1970, so a 1960 file counts as newer than a 1965 reference. GNU find needs the file to be strictly newer:The reference milliseconds are now turned into a
SystemTimeon either side of the epoch and compared with>against the file'sSystemTime, which also drops theexpecton the millisecond conversion.New unit test
newer_time_matcher_is_strict_and_signedsets the file's mtime withFile::set_modifiedand fails without the change.cargo test: 430 passed, clippy and fmt clean. Both commands above now print the same as GNU find 4.10.0.