Skip to content

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

Open
nkgotcode wants to merge 1 commit into
uutils:mainfrom
nkgotcode:fix/cp-parents-dotdot
Open

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

Conversation

@nkgotcode
Copy link
Copy Markdown

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
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

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!

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 ..

1 participant