-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
install: fix issue #3814 #3950
install: fix issue #3814 #3950
Conversation
I guess you saw:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping?
Sorry for the late reply. Was a little busy. Yes I know of this. The problem has been there before: When a non-existing directory path is given as target ending on a '/', the install command fails, but with a wrong error message. At least it is not the same as the original GNU install does. I also already have a fix for unix systems. I will push it now. |
Install is currently unix-only. You can check that in the docs (https://uutils.github.io/coreutils-docs/user/utils/install.html, icons in the top right). Or in the global Cargo.toml, though it is a bit hard to read. |
But I wonder if there is a good reason not to run on Windows? |
I've that seen in the Cargo.toml, but I also think that I've found some special test cases for Windows - something about very long filenames or so. Therefore I was unsure. Can this pull request be merged then? |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
While trying to increase the code coverage, I tried some more test cases and compared them with the orig. GNU install. Here's the test code to try it our yourself:
|
GNU testsuite comparison:
|
Code was missing the logic to create the target dir when multiple files should be copied and target dir is given by -t option. This simplifies the copy logic also when only one file should be copied to the target dir.
Also adds a unit test to verify the same behaviour as the gnu tools.
Tests various combinations of "-D" with and w/o "-t" when installing either a single file or multiple files into a non existing directory. install -D file1 file2 (-t) not_existing_dir install -D file1 (-t) not_existing_dir/ Also fixes file formatting, spelling and adds some more test asserts.
The install command failed with a different error message than the original GNU install tool. Checking for a trailing slash fixes this. Only works on unix though.
This increases the CI test coverage and also checks for more corner cases to ensure uu_install is compliant with GNU's original. export C=coreutils/target/debug/ rm -rf dir1 no-dir2 dir3 file mkdir -p dir1 dir3 touch file ${C}install dir1/file1 dir1/.. no-dir2 ${C}install dir1/file1 dir1/.. dir3 ${C}install dir1/.. dir3
Also check that install returns the correct error messages, when only a target directory is given via -t and that is is not created (-D option).
This ensures correct (GNU install like) behavior. Tests from the last commit will pass now.
9ede8f8
to
ea8dd62
Compare
GNU testsuite comparison:
|
1 similar comment
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question, otherwise ready to be merged I think! Sorry for taking so long :)
#[cfg(not(unix))] | ||
fn is_potential_directory_path(path: &Path) -> bool { | ||
let path_str = path.to_string_lossy(); | ||
path_str.ends_with(MAIN_SEPARATOR) || path_str.ends_with('/') || path.is_dir() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if the second case here is really expected behaviour. Does windows accept trailing /
in paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question, otherwise ready to be merged I think! Sorry for taking so long :)
No worries! We all have personal lives sometimes :)
I'm wondering if the second case here is really expected behaviour. Does windows accept trailing
/
in paths?
AFAIK it does. I'm not sure, whether that is a valid delimiter in the standard cmd.exe or powershell already, or if this is only allowed when you use a MinGW or Git-bash shell. Nonetheless you can find the same check already in here uucore::features::fs::canonicalize()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let has_to_be_directory =
(miss_mode == MissingHandling::Normal || miss_mode == MissingHandling::Existing) && {
let path_str = original.to_string_lossy();
path_str.ends_with(MAIN_SEPARATOR) || path_str.ends_with('/')
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright! Sounds good. We can merge this if you fix the conflicts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The branch is now up to date. Still merging is not possible.
Am I missing something @sylvestre and @tertsdiepraam ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the main of your repo is not up to date with the upstream one? I usually do something like this to ensure my main is set to the upstream one:
git switch main
git fetch upstream
git reset --hard upstream/main
Note: this will delete any changes on your local main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, merging is blocked because of the requested changes by @sylvestre, it doesn't have anything to do with git.
GNU testsuite comparison:
|
yeah, thanks, approved! |
This pull request fixes the the issue mentioned in #3814, so installing multiple files using the "create leading dirs" option combined with the target parameter is now working and the GNU test is passing.
Furthermore this PR fixes more issues: