Skip to content

cp, mv: let the last of -u and --update win - #16880

Merged
sylvestre merged 2 commits into
uutils:mainfrom
binhvq:update-last-option-wins
Nov 27, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
binhvq:update-last-option-wins

Conversation

@binhvq

@binhvq binhvq commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

--update=WHEN always took precedence over -u, whatever the order, so mv --update=none -u -b was rejected and cp --update=all -u overwrote a newer destination. The two args now override each other in uucore's update_control, so clap keeps the last one; this also lets mv take -u more than once.

Closes #16879

--update=WHEN always took precedence over -u, whatever their order, so
`mv --update=none -u -b` was rejected and `cp --update=all -u` overwrote
a newer destination. Make the two options override each other, which also
lets mv accept -u more than once.
@codspeed

codspeed Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 20.49%

2 warnings, 1 note

⚠️ 127 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
✅ 414 untouched benchmarks
⏩ 70 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation mv_force_overwrite 155.9 ms 129.4 ms +20.49%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing binhvq:update-last-option-wins (1b6f1d6) with main (932efe9)2

Open in CodSpeed

Footnotes

  1. 70 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. ↩

  2. No successful run was found on main (6dcc23e) during the generation of this report, so 932efe9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread tests/by-util/test_cp.rs
#[rstest]
#[case::all(&["--update=all", "-u"])]
#[case::none_with_backup(&["--update=none", "-u", "-b"])]
#[case::all_between_short(&["-u", "--update=all", "-u"])]

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.

could you please also add the other direction, e.g. -u --update=all overwriting dest? thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added test_cp_arg_update_long_after_short: -u --update=all (also with -u twice and with -b) now has to overwrite the newer dest.

Comment thread tests/by-util/test_mv.rs
#[rstest]
#[case::none(&["--update=none", "-u"])]
#[case::none_fail(&["--update=none-fail", "-u"])]
#[case::none_with_backup(&["--update=none", "-u", "-b"])]

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.

maybe also check that dest~ is created in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, the test now checks that dest~ exists when -b is given and not otherwise.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre
sylvestre merged commit 8fbf3bd into uutils:main Nov 27, 2026
194 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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, mv: --update=WHEN always wins over -u, whatever the order

2 participants