Skip to content

cp: fix --remove-destination deleting source when dest is the same file under a different path#13135

Open
LoukasPap wants to merge 1 commit into
uutils:mainfrom
LoukasPap:issue13103
Open

cp: fix --remove-destination deleting source when dest is the same file under a different path#13135
LoukasPap wants to merge 1 commit into
uutils:mainfrom
LoukasPap:issue13103

Conversation

@LoukasPap

Copy link
Copy Markdown

Fixes #13103

Problem

It compared the source and destination inputs as passed, so for example "a" and "./a" were compared and were -of course- found different.

Solution

We convert them to absolute paths using canonicalize(...) and then perform the equality check.

@codspeed-hq

codspeed-hq Bot commented Jun 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 323 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing LoukasPap:issue13103 (070a2de) with main (e73b8a6)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/rm/isatty (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tty-eof (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout-group (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!

@LoukasPap

LoukasPap commented Jun 27, 2026

Copy link
Copy Markdown
Author

Is there a way to test the performance locally or before pushing?

@LoukasPap

Copy link
Copy Markdown
Author

Changed order of conditions to allow same-file check to happen only when --remove-destination param is set, thus avoiding redundant comparison of source and dest.

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.

bug(cp): --remove-destination option check is the same file can be bypassed

1 participant