Skip to content

find: compare selected timestamps for -newerXY - #886

Open
SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:find-newerxy-timestamps
Open

SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:find-newerxy-timestamps

Conversation

@SichenLiang

Copy link
Copy Markdown
Contributor

-newerXY always used the reference mtime regardless of Y, and required both the candidate's X and Y timestamps to be newer than it. Compare the candidate's X timestamp directly with the reference's Y timestamp instead.

This fixes -anewer and -cnewer when the candidate's mtime is older but the selected timestamp is newer.

Reference symlinks now follow the active dereference mode: -P uses the link timestamp, while -H and -L use the target timestamp, or the link's own timestamp if the target does not exist. Because -follow takes effect where it appears in the expression, it changes reference handling only for later predicates. This matches the GNU find documentation.

On Windows, Y=c is rejected during parsing with find: unsupported and status 1 because a change time for the reference is unavailable.

Fixes #885

Select the reference file's Y timestamp when building the matcher, then
compare only the candidate's X timestamp. This fixes -newerXY when Y is
not m and lets -anewer/-cnewer match even when the candidate's mtime is
older than the reference mtime.

Read reference symlinks according to -P/-H/-L: -P uses the link's time.
Under -H/-L, reference paths to -newer, -anewer, and -cnewer "are
dereferenced and the timestamp from the pointed-to file is used
instead (if possible – otherwise the timestamp from the symbolic link
is used)." GNU find manual, "Symbolic Links" section:
https://www.gnu.org/software/findutils/manual/find.html

A later -follow changes reference handling only for later predicates.

On Windows, -newerXc now fails while parsing with "find: unsupported"
and status 1 because change time is unavailable as a reference
timestamp.
@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.70093% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.01%. Comparing base (f0b2ee9) to head (6d34680).

Files with missing lines Patch % Lines
src/find/matchers/time.rs 74.22% 19 Missing and 6 partials ⚠️
src/find/matchers/mod.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #886      +/-   ##
==========================================
- Coverage   92.27%   92.01%   -0.26%     
==========================================
  Files          35       35              
  Lines        7576     7656      +80     
  Branches      393      401       +8     
==========================================
+ Hits         6991     7045      +54     
- Misses        443      463      +20     
- Partials      142      148       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Sep 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing SichenLiang:find-newerxy-timestamps (6d34680) with main (f0b2ee9)

Open in CodSpeed

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.

find: -cnewer rejects a newer ctime when the mtime is older

1 participant