Repository navigation
mv: allow moving a symlink onto another hard link - #17071
Open
tonycoder-hub wants to merge 1 commit into
Open
tonycoder-hub wants to merge 1 commit into
tonycoder-hub wants to merge 1 commit into
Conversation
A symlink and a different hard link of its referent were reported as the same file, so mv refused a move that only replaces that name and leaves the file reachable through the remaining links. The name the symlink points at, and a file with a single link, are still refused. Signed-off-by: Tony Coder <407243179@qq.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mv s hrefused whenswas a symlink tofandhwas another hard link off, reporting that they were the same file and exiting 1. Replacinghonly removes one name; the file stays reachable throughf, and GNUmvperforms this move.The same-file check now allows the move when the source is a symlink, its canonical path differs from the destination, and the destination has more than one link (counted via
uucore::fs::FileInformation::number_of_links, so the symlink is not dereferenced). Moving the symlink onto the name it points at, or onto a file that has only one link, is still refused. Two hard links of the same symlink are still refused by the existing hard-link check.Closes #17040
Testing
test_mv_symlink_onto_other_hard_link_of_referentfails onmain(mv: 's' and 'h' are the same file) and passes with this change.cargo test --no-default-features --features mv --test tests test_mv::(167 passed)cargo fmt --all -- --check,cargo clippy -p uu_mv --all-targets -- -D warnings,cargo check -p uu_mv --target x86_64-pc-windows-gnumv9.4 binary (no GNU source consulted).This change was prepared with AI assistance and verified by the tests above.