Skip to content

mv: show "same file" error for mv d/f d #5788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

cakebaker
Copy link
Contributor

When using mv d/f d, GNU mv fails with a "same file" error whereas uutils mv doesn't fail. This PR makes uutils mv fail, too.

@samueltardieu
Copy link
Contributor

samueltardieu commented Jan 5, 2024

I wonder if this is the right fix. GNU mv fails at moving t/a into u/b if u/b exist and is the same file as t/a (hard link), while your patch seems to compare parents.

Reproducer:

$ mkdir t u
$ touch t/a
$ ln t/a u/a
$ mv t/a u
mv: 't/a' and 'u/a' are the same file

With your patch:

$ […]/target/debug/coreutils mv t/a u
[success]

@cakebaker
Copy link
Contributor Author

Thanks for your feedback. I didn't consider hard links when creating this PR :|

@cakebaker cakebaker marked this pull request as draft January 5, 2024 14:03
@samueltardieu
Copy link
Contributor

I think you can reuse/move around most of the code just before your patch. IIRC, it checks for hardlink equivalence when the target is a file, so if you build the target file name in case you get a directory I guess you might use the same check.

@sylvestre
Copy link
Contributor

@cakebaker ping ? :)

Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/mv/mv-n is no longer failing!
Congrats! The gnu test tests/mv/update is no longer failing!
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre marked this pull request as ready for review December 2, 2024 19:37
@sylvestre sylvestre merged commit 527bb6f into uutils:main Dec 2, 2024
62 checks passed
@sylvestre
Copy link
Contributor

sorry, i missunderstood, it, reverting it

@sylvestre
Copy link
Contributor

please reopen when ready :)

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.

3 participants