-
- Notifications
You must be signed in to change notification settings - Fork 1.6k
ls: Implement -f flag to disable sorting and enable -a #8824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| GNU testsuite comparison: |
a5f514a to 5f04d3d Compare | GNU testsuite comparison: |
…ation Fix the -f flag implementation to properly enable all files display, disable sorting, and handle color output correctly. Changes: - Correct UNSORTED_ALL constant from 'unsorted-all' to 'f' - Fix color logic to honor explicit --color flag regardless of -f position - Add French localization for ls-help-unsorted-all - Add comprehensive integration tests for -f flag behavior The explicit --color flag now always takes precedence over -f implicit color disabling, matching expected CLI behavior.
5f04d3d to ce25b4d Compare | GNU testsuite comparison: |
CodSpeed Performance ReportMerging #8824 will improve performances by 2.98%Comparing Summary
Benchmarks breakdown
Footnotes
|
Address maintainer feedback from PR uutils#8824 review: 1. test_f_flag_disables_sorting: Compare -f output with -a (sorted) and -U (unsorted) to prove sorting is actually disabled, not just that files appear in output 2. test_f_overrides_big_a: Rename from test_f_overrides_a_and_big_a and fix assertions to check for .. presence (distinguishes -f from -A) instead of .hidden (shown in both) 3. test_f_overrides_sort_flags: Use size-based files and explicit output comparisons to verify last-flag-wins behavior with deterministic ordering 4. test_big_u_overrides_f_sort: Use size-based files and verify -U participates in last-flag-wins by checking actual output order All tests now properly validate flag interactions instead of just checking file presence.
Replace if/else chain with match expression for improved readability and more idiomatic Rust code. Uses match guards for index comparisons. Addresses maintainer feedback from PR uutils#8824 review. No functional changes - behavior remains identical.
|
Address maintainer feedback from PR uutils#8824 review: Tests improvements: 1. test_f_flag_disables_sorting: Compare -f output with -a (sorted) and -U (unsorted) to prove sorting is disabled, not just that files appear in output 2. test_f_overrides_big_a: Rename from test_f_overrides_a_and_big_a and check .. presence (distinguishes -f from -A) instead of .hidden (shown in both) 3. test_f_overrides_sort_flags: Use size-based files with explicit output comparisons to verify last-flag-wins with deterministic ordering 4. test_big_u_overrides_f_sort: Use size-based files and verify -U participates in last-flag-wins by checking actual output order Code refactoring: 5. extract_sort(): Replace if/else chain with match expression for improved readability All variable names now follow snake_case convention to fix lint warnings.
f258c79 to ce25b4d Compare ce25b4d to 3b8264a Compare Address maintainer feedback from PR uutils#8824 review: 1. test_f_flag_disables_sorting: Compare -f output with -a (sorted) and -U (unsorted) to prove sorting is actually disabled, not just that files appear in output 2. test_f_overrides_big_a: Rename from test_f_overrides_a_and_big_a and fix assertions to check for .. presence (distinguishes -f from -A) instead of .hidden (shown in both) 3. test_f_overrides_sort_flags: Use size-based files and explicit output comparisons to verify last-flag-wins behavior with deterministic ordering 4. test_big_u_overrides_f_sort: Use size-based files and verify -U participates in last-flag-wins by checking actual output order All tests now properly validate flag interactions instead of just checking file presence.
Replace if/else chain with match expression for improved readability and more idiomatic Rust code. Uses match guards for index comparisons. Addresses maintainer feedback from PR uutils#8824 review. No functional changes - behavior remains identical.
Follow Rust naming conventions by converting variable names in -f flag tests from mixed case (out_Af, out_fS, etc.) to snake_case (out_a_f, out_f_s, etc.). This eliminates clippy warnings about non_snake_case identifiers.
a93c861 to baf2dd5 Compare The tests test_f_flag_disables_sorting, test_big_u_overrides_f_sort, and test_f_overrides_sort_flags made incorrect assumptions that unsorted directory order would always differ from sorted order. However, fs::read_dir() returns entries in filesystem-dependent order which may accidentally match sorted order on some filesystems. Changes: - Removed assertions comparing unsorted vs sorted outputs - Added deterministic checks (e.g., verifying --sort after -f works) - Added explicit order verification for size-sorted outputs - Tests now verify flag precedence without relying on directory order Fixes CI failures on Windows and SELinux platforms. Quality checks passed: - cargo fmt --check: ✓ - cargo clippy --test tests: ✓ - all 3 modified tests pass: ✓
8127250 to 0be0a8d Compare | GNU testsuite comparison: |
Renamed test_big_u_overrides_f_sort to test_big_u_participates_in_sort_flag_wins to accurately reflect that it tests -U with -S interactions, not -f.
| GNU testsuite comparison: |
| GNU testsuite comparison: |
| Thanks! |
* ls: implement -f flag with correct constant, color logic, and localization Fix the -f flag implementation to properly enable all files display, disable sorting, and handle color output correctly. Changes: - Correct UNSORTED_ALL constant from 'unsorted-all' to 'f' - Fix color logic to honor explicit --color flag regardless of -f position - Add French localization for ls-help-unsorted-all - Add comprehensive integration tests for -f flag behavior The explicit --color flag now always takes precedence over -f implicit color disabling, matching expected CLI behavior. * tests(ls): improve -f flag test assertions Address maintainer feedback from PR uutils#8824 review: 1. test_f_flag_disables_sorting: Compare -f output with -a (sorted) and -U (unsorted) to prove sorting is actually disabled, not just that files appear in output 2. test_f_overrides_big_a: Rename from test_f_overrides_a_and_big_a and fix assertions to check for .. presence (distinguishes -f from -A) instead of .hidden (shown in both) 3. test_f_overrides_sort_flags: Use size-based files and explicit output comparisons to verify last-flag-wins behavior with deterministic ordering 4. test_big_u_overrides_f_sort: Use size-based files and verify -U participates in last-flag-wins by checking actual output order All tests now properly validate flag interactions instead of just checking file presence. * refactor(ls): use match expression in extract_sort Replace if/else chain with match expression for improved readability and more idiomatic Rust code. Uses match guards for index comparisons. Addresses maintainer feedback from PR uutils#8824 review. No functional changes - behavior remains identical. * fix(ls): use snake_case for test variable names Follow Rust naming conventions by converting variable names in -f flag tests from mixed case (out_Af, out_fS, etc.) to snake_case (out_a_f, out_f_s, etc.). This eliminates clippy warnings about non_snake_case identifiers. * tests: fix flaky ls tests that depend on filesystem directory order The tests test_f_flag_disables_sorting, test_big_u_overrides_f_sort, and test_f_overrides_sort_flags made incorrect assumptions that unsorted directory order would always differ from sorted order. However, fs::read_dir() returns entries in filesystem-dependent order which may accidentally match sorted order on some filesystems. Changes: - Removed assertions comparing unsorted vs sorted outputs - Added deterministic checks (e.g., verifying --sort after -f works) - Added explicit order verification for size-sorted outputs - Tests now verify flag precedence without relying on directory order Fixes CI failures on Windows and SELinux platforms. Quality checks passed: - cargo fmt --check: ✓ - cargo clippy --test tests: ✓ - all 3 modified tests pass: ✓ * test: fix misleading test name for -U flag behavior Renamed test_big_u_overrides_f_sort to test_big_u_participates_in_sort_flag_wins to accurately reflect that it tests -U with -S interactions, not -f.
Summary
Adds the
-fflag tols, matching GNU behavior:-a(shows all files including.and..)--color(explicit--colorstill works)Partially addresses #1872.
Implementation
Used index-based last-flag-wins logic (same pattern as
--zeroflag):ls -f -tsorts by time (last flag wins)ls -t -fno sorting (last flag wins)ls -f --color=alwaysshows color (explicit overrides implicit disable)