Skip to content
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

ls: fix for gnu test case quote-align compatibility #6555

Closed
wants to merge 5 commits into from

Conversation

matrixhead
Copy link
Contributor

This pr tries to solve #6554

Copy link

github-actions bot commented Jul 9, 2024

GNU testsuite comparison:

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

@matrixhead matrixhead force-pushed the quote-align branch 2 times, most recently from 31daa7f to f9141fb Compare July 10, 2024 07:13
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/ls/quote-align is no longer failing!

@matrixhead
Copy link
Contributor Author

one thing I noticed while writing tests is that when c quoting style is given gnu ls tries to escape ':', I couldn't understand why they're doing this, but I think I matched the behavior.

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/ls/quote-align is no longer failing!

Copy link

GNU testsuite comparison:

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

Copy link
Contributor

@RenjiSann RenjiSann left a comment

Choose a reason for hiding this comment

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

The comments I made make me slightly more confident in #6559. I added the patch to fix the quote-align test to it.

Another strong point of 6559 is the number of tests I added. This should help us to avoid regressions in the future.

Comment on lines +300 to +304
pub fn escape_name(
name: &OsStr,
style: &QuotingStyle,
additional_escaped_chars: &[char],
) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Because escape_name is used in many places, and its additional_escaped_chars argument is acually used only once, I'd like to avoid having to add &[] to all the other function calls.

The way I did it in #6559 was just to rename the function to escape_name_inner, which actually take the parameter, and escape_name just calls escape_name_inner with &[].

That way, you can create escape_dirname which calls escape_name_inner with &[':'].

pub fn escape_name(
name: &OsStr,
style: &QuotingStyle,
additional_escaped_chars: &[char],
Copy link
Contributor

Choose a reason for hiding this comment

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

As a broader remark, I decided to go with a simple boolean for dirname ?, rather than a list of escaped characters, because I don't think there are other edge cases.

Yet that absence of other edge cases might be wrong, so I don't really know what to choose here

@matrixhead
Copy link
Contributor Author

The test cases alone make #6559 a better PR, so I'm closing this in favor of #6559.

@matrixhead matrixhead closed this Jul 26, 2024
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