Repository navigation
Conversation
sylvestre
reviewed
Dec 1, 2026
| let parents_dest = if options.parents { | ||
| // Strip the filesystem root (the empty path for a relative source) | ||
| // so even an absolute source stays underneath the target. | ||
| let prefix = root.ancestors().last().unwrap_or(root); |
Contributor
There was a problem hiding this comment.
cp.rs construct_dest_path already computes this root (has_root() && cfg!(unix)). Could it be shared, so files and dirs agree on Windows too?
| #[cfg(unix)] | ||
| #[uutests::wasi_ignore(HostPathsNotVisible)] | ||
| #[test] | ||
| fn test_cp_parents_recursive_absolute_source_ending_in_dot() { |
Contributor
There was a problem hiding this comment.
this also changes cp -R --parents /abs/dir backup without the trailing /., please add a test for that case too
| // A source ending in /. is walked relative to the directory itself. | ||
| // Its full --parents destination is therefore the traversal target. | ||
| if ends_with_dot_component(root) { | ||
| parents_dest.join(".") |
Contributor
There was a problem hiding this comment.
why join(".")? is it only for the verbose output?
limadog9
force-pushed
the
fix/cp-parents-trailing-dot-17050
branch
from
December 1, 2026 20:21
d6ee835 to
808084d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the full destination for a source ending in
/.so refreshing an existing backup updates the intended directory. Regression tests cover relative and absolute source paths.Closes #17050