Repository navigation
cp, mv: let the last of -u and --update win - #16880
Conversation
--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.
Merging this PR will improve performance by 20.49%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
| #[rstest] | ||
| #[case::all(&["--update=all", "-u"])] | ||
| #[case::none_with_backup(&["--update=none", "-u", "-b"])] | ||
| #[case::all_between_short(&["-u", "--update=all", "-u"])] |
There was a problem hiding this comment.
could you please also add the other direction, e.g. -u --update=all overwriting dest? thanks
There was a problem hiding this comment.
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.
| #[rstest] | ||
| #[case::none(&["--update=none", "-u"])] | ||
| #[case::none_fail(&["--update=none-fail", "-u"])] | ||
| #[case::none_with_backup(&["--update=none", "-u", "-b"])] |
There was a problem hiding this comment.
maybe also check that dest~ is created in this case?
There was a problem hiding this comment.
Done, the test now checks that dest~ exists when -b is given and not otherwise.
|
GNU testsuite comparison: |
|
Thanks for your PR |
--update=WHENalways took precedence over-u, whatever the order, somv --update=none -u -bwas rejected andcp --update=all -uoverwrote 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-umore than once.Closes #16879