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 degrade performance by 39.23%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 5 regressed benchmarks
✅ 318 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cp_recursive_deep_tree[(120, 4)] 13 ms 40.8 ms -68.06%
Simulation cp_recursive_balanced_tree[(5, 4, 10)] 70.5 ms 102.1 ms -30.9%
Simulation cp_preserve_metadata[(5, 4, 10)] 73.5 ms 105.5 ms -30.32%
Simulation cp_archive_balanced_tree[(5, 4, 10)] 76.8 ms 108.3 ms -29.11%
Simulation cp_recursive_wide_tree[(6000, 800)] 184.1 ms 242.3 ms -24%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing LoukasPap:issue13103 (eadcff4) 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

Copy link
Copy Markdown

GNU testsuite comparison:

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