Skip to content

mv: don't skip a directory source with -u - #17011

Open
seragAhmed wants to merge 2 commits into
uutils:mainfrom
seragAhmed:fix/17003-mv-update-directory
Open

seragAhmed wants to merge 2 commits into
uutils:mainfrom
seragAhmed:fix/17003-mv-update-directory

Conversation

@seragAhmed

Copy link
Copy Markdown
Contributor

mv -u dir dest/ returned early when dest/dir was an existing directory at least as new as the source, so nothing was moved and nothing was reported. The GNU manual limits the -u timestamp skip to non-directory sources, and GNU mv does move the directory here.

The check now only skips when the source isn't a directory; a directory always goes on to the rename, which still fails if the destination directory isn't empty. Added a Unix test that sets the source directory's mtime to the epoch and moves it onto a fresh empty directory.

Fixes #17003

--update only skips a non-directory whose destination is not older. A
directory onto an existing empty directory with a newer or equal timestamp
was skipped silently, leaving everything in the source.
@codspeed

codspeed Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will regress 2 benchmarks

1 warning

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

⚡ 3 improved benchmarks
❌ 2 regressed benchmarks
✅ 3 untouched benchmarks
⏩ 478 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation mv_force_overwrite 127.8 ms 170.5 ms -25.03%
❌ CPU Simulation mv_single_file 124.2 ms 154.4 ms -19.61%
⚡ CPU Simulation mv_directory 6,432.7 µs 588.6 µs ×11
⚡ Memory mv_directory 314.5 KB 122.2 KB ×2.6
⚡ Memory mv_multiple_to_dir 458.4 KB 442.8 KB +3.53%

Tip

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


Comparing seragAhmed:fix/17003-mv-update-directory (2a35c31) with main (53ca8ad)2

Open in CodSpeed

Footnotes

  1. 478 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 (2a072db) during the generation of this report, so 53ca8ad 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_mv.rs

assert!(!at.dir_exists("release"));
assert_eq!(at.read("stage/release/manifest"), "package\n");
}

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 a case where stage/release isn't empty? it should fail now instead of silently skipping

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 in 2f935ed: test_mv_update_dir_onto_newer_non_empty_dir_fails puts a file in stage/release, and mv -u release stage now fails with "Directory not empty" and leaves both directories as they were.

@seragAhmed

Copy link
Copy Markdown
Contributor Author

About the CodSpeed result: it compares against 53ca8ad, not this PR's base 2a072db, since there was no successful run on 2a072db. #15912 and the benchmark change in #14965 fall in that gap. This PR only touches the --update=older branch, which neither mv_single_file nor mv_force_overwrite runs.

This branch has not been deployed

No deployments
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.

mv -u silently skips an entire directory when the destination directory has an equal or newer timestamp

2 participants