Skip to content

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

Merged
sylvestre merged 1 commit intouutils:mainfrom
cakebaker:mv_same_file
Dec 2, 2024
Merged

mv: show "same file" error for mv d/f d#5788
sylvestre merged 1 commit intouutils:mainfrom
cakebaker:mv_same_file

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 ? :)

@github-actions
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
@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