Skip to content

ls: correct the order of custom time formats - #14780

Open
ddy314 wants to merge 3 commits into
uutils:mainfrom
ddy314:fix/ls-custom-time-order
Open

ddy314 wants to merge 3 commits into
uutils:mainfrom
ddy314:fix/ls-custom-time-order

Conversation

@ddy314

@ddy314 ddy314 commented Sep 21, 2026

Copy link
Copy Markdown

Custom time styles put the non-recent format before the newline and the recent format after it. Reverse the current mapping, retain single-format behavior, and cover empty halves through both the option and TIME_STYLE.

Refs #14727 (the two-format ordering; other strftime cases remain).

Validation: 186 ls tests passed, 1 ignored; Clippy and rustfmt passed.

AI-assisted with Codex.

Copilot AI lite review requested due to automatic review settings September 21, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Fixes ls custom time-style parsing so that two-format strings interpret the first line as the non-recent (older) format and the second line as the recent format, while keeping single-format behavior and handling empty halves consistently across --time-style and TIME_STYLE.

Changes:

  • Reverse mapping for +FORMAT1\nFORMAT2 so FORMAT1 applies to non-recent and FORMAT2 to recent files.
  • Preserve single-format behavior and support empty “older”/“recent” halves.
  • Add tests covering option vs TIME_STYLE, single vs two formats, and empty halves.
File Description
tests/​by-util/​test_ls.rs Updates existing expectations and adds coverage for custom two-format ordering and empty halves via option/env.
src/​uu/​ls/​src/​config.rs Adjusts parse_time_style parsing/mapping logic for custom +... time styles to match intended ordering.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uu/ls/src/config.rs Outdated
Comment thread tests/by-util/test_ls.rs Outdated
Comment thread tests/by-util/test_ls.rs Outdated
@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/ls/ls-time is no longer failing!

Copilot AI review requested due to automatic review settings September 22, 2026 06:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/uu/ls/src/config.rs Outdated
match it.next() {
None => ok((recent, older)),
Some(_) => Err(LsError::TimeStyleParseError(String::from(field))),
let older = it.next().unwrap_or_default();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

older is passed as the recent format just below, could you rename it to first? it reads wrong otherwise

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the first parsed format to first in c0212f7. It is used for both timestamps when there is no newline, and for older timestamps when there is one.

Comment thread tests/by-util/test_ls.rs Outdated
}

#[test]
fn test_ls_custom_time_style_recent_and_older() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overlaps quite a bit with test_ls_time_styles, could the new empty-half cases go there instead? thanks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the empty-half and environment cases into test_ls_time_styles in c0212f7, reusing its recent and old fixtures. The focused test and clippy pass.

Copilot AI review requested due to automatic review settings September 23, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codspeed

codspeed Bot commented Sep 23, 2026

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
❌ 2 regressed benchmarks
✅ 382 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation three_39_bit_primes 419.2 ms 647.9 ms -35.3%
Simulation du_wide_tree[(5000, 500)] 18.4 ms 18.9 ms -3.01%
Simulation complex_relative_date 400.3 µs 288.2 µs +38.86%
Simulation five_38_bit_primes 2.1 s 1.8 s +22.09%
Simulation thirteen_39_bit_primes 9.3 s 8.8 s +5.89%
Simulation du_deep_tree[(100, 3)] 2.2 ms 2.1 ms +3.28%
Simulation ls_recursive_deep_tree[(200, 2)] 3.4 ms 3.3 ms +3.19%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ddy314:fix/ls-custom-time-order (c0212f7) with main (b947458)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

This branch has not been deployed

No deployments
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.

3 participants