Skip to content
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

mv: improve move-to-self error handling #6995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sgvictorino
Copy link
Contributor

  • improve move-to-self detection, so this errors without data loss:
 mkdir mydir
 mv mydir mydir/subdir
-mv: No such file or directory (os error 2)
+mv: cannot move 'mydir' to a subdirectory of itself, 'mydir/subdir'
  • align "cannot move source to a subdirectory of itself" and "same file"
    errors more closely with coreutils:
 mkdir mydir
 mv mydir/ mydir/..
-mv: cannot move 'mydir/' to a subdirectory of itself, 'mydir/../mydir/'
+mv: 'mydir/' and 'mydir/../mydir' are the same file

@sgvictorino sgvictorino force-pushed the improve-mv-to-self-errors branch from b0ef406 to 5af8055 Compare December 23, 2024 21:36
Copy link

GNU testsuite comparison:

GNU test failed: tests/mv/atomic. tests/mv/atomic is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/mv/part-symlink. tests/mv/part-symlink is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sgvictorino sgvictorino marked this pull request as draft December 24, 2024 00:37
@sgvictorino sgvictorino force-pushed the improve-mv-to-self-errors branch 3 times, most recently from 7f5d2d2 to c983180 Compare December 24, 2024 03:49
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sgvictorino sgvictorino force-pushed the improve-mv-to-self-errors branch from c983180 to 2425ccc Compare December 24, 2024 04:22
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@sgvictorino sgvictorino force-pushed the improve-mv-to-self-errors branch 2 times, most recently from 3ce0134 to ddbb07b Compare December 24, 2024 17:49
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

- improve move-to-self detection, so this errors without data loss:

```diff
 mkdir mydir
 mv mydir mydir/subdir
-mv: No such file or directory (os error 2)
+mv: cannot move 'mydir' to a subdirectory of itself, 'mydir/subdir'
```

- align "cannot move source to a subdirectory of itself" and "same file"
  errors more closely with coreutils:

```diff
 mkdir mydir
 mv mydir/ mydir/..
-mv: cannot move 'mydir/' to a subdirectory of itself, 'mydir/../mydir/'
+mv: 'mydir/' and 'mydir/../mydir' are the same file
```
@sgvictorino sgvictorino force-pushed the improve-mv-to-self-errors branch from ddbb07b to f104ba0 Compare December 24, 2024 20:21
@sgvictorino sgvictorino marked this pull request as ready for review December 24, 2024 20:35
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

is there a bug somewhere or it is just something you identified ?

) -> UResult<()> {
let target_is_dir = target_is_dir && !opts.no_target_dir;

let canonicalized_source = match canonicalize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add some comments explaining the different cases ?

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.

2 participants