Skip to content

mv: add --exchange to atomically swap two paths#13215

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:mv-exchange
Open

mv: add --exchange to atomically swap two paths#13215
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:mv-exchange

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Should make test tests/mv/mv-exchange.sh pass

Should make test tests/mv/mv-exchange.sh pass
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/mv/mv-exchange is no longer failing!
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@codspeed-hq

codspeed-hq Bot commented Jun 29, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.62%

⚠️ 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

❌ 4 regressed benchmarks
✅ 323 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation mv_force_overwrite 62.8 ms 66 ms -4.87%
Simulation sort_ascii_c_locale 16 ms 16.7 ms -4.67%
Simulation sort_ascii_utf8_locale 15.4 ms 16.1 ms -4.65%
Simulation mv_single_file 62.6 ms 65.4 ms -4.28%

Tip

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


Comparing sylvestre:mv-exchange (df4ba34) with main (b76d615)

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.

Comment thread tests/by-util/test_mv.rs
Comment on lines +3267 to +3293
fn test_mv_exchange_wrong_operand_count() {
let scene = TestScenario::new(util_name!());
scene.fixtures.write("only", "x");

// A single operand is rejected.
scene
.ucmd()
.arg("--exchange")
.arg("only")
.fails()
.code_is(1);

// Three operands are rejected too.
scene.fixtures.write("two", "y");
scene.fixtures.write("three", "z");
scene
.ucmd()
.arg("--exchange")
.arg("only")
.arg("two")
.arg("three")
.fails()
.code_is(1);
}

#[test]
fn test_mv_exchange_missing_target() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also check for the error messages. Currently the two tests pass even without the changes you did to mv.rs

Comment thread tests/by-util/test_mv.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also test the scenario where source and target are the same file.

Comment thread tests/by-util/test_mv.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNU mv also supports a use case with more than two operands:

$ touch a b c
$ mkdir myfolder
$ touch myfolder/a myfolder/b myfolder/c
$ mv --exchange -v a b c myfolder/
exchanged 'a' <-> 'myfolder/a'
exchanged 'b' <-> 'myfolder/b'
exchanged 'c' <-> 'myfolder/c'

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.

2 participants