Skip to content

cp: handle --parents source ending in parent dir#12639

Merged
cakebaker merged 1 commit into
uutils:mainfrom
nkgotcode:fix/cp-parents-dotdot
Jun 17, 2026
Merged

cp: handle --parents source ending in parent dir#12639
cakebaker merged 1 commit into
uutils:mainfrom
nkgotcode:fix/cp-parents-dotdot

Conversation

@nkgotcode

Copy link
Copy Markdown
Contributor

Fixes #12626.

When cp --parents -r receives a source path that ends in .., the parent-permission copy path can reach a root path without a file name and panic. This keeps that path on the existing error path instead, matching GNU coreutils behavior for the repro case.

The regression test covers the trailing-parent-dir source and asserts the command exits with the expected directory-exists error instead of panicking or silently succeeding.

Validation:

  • cargo test --features cp --test tests test_cp::test_cp_parents_recursive_source_ending_in_parent_dir -- --exact
  • cargo test --features cp --test tests test_cp::test_cp_parents_2_dir -- --exact
  • manual repro: coreutils cp --parents -r src/sub/.. d exits 1 with cp: cannot create directory 'd/src/sub/..': File exists, leaves d/src/sub, and does not copy src/sub/f
  • _default/scripts/verify-no-ai-coauthor.sh passed immediately before push

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.
Congrats! The gnu test tests/cut/bounded-memory is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!

@cakebaker cakebaker merged commit 28922ff into uutils:main Jun 17, 2026
174 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks for your PR!

@nkgotcode nkgotcode deleted the fix/cp-parents-dotdot branch June 18, 2026 12:33
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.

cp panics (unwrap None) on --parents with a source path ending in ..

2 participants