Skip to content

Commit c45f346

Browse files
authored
Merge pull request #6905 from uutils/revert-5788-mv_same_file
Revert "mv: show "same file" error for `mv d/f d`"
2 parents 527bb6f + 9877085 commit c45f346

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

src/uu/mv/src/mv.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
314314
)
315315
.into());
316316
}
317-
318317
if source.symlink_metadata().is_err() {
319318
return Err(if path_ends_with_terminator(source) {
320319
MvError::CannotStatNotADirectory(source.quote().to_string()).into()
@@ -337,13 +336,6 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
337336
}
338337
}
339338

340-
if source.parent() == Some(target) {
341-
return Err(
342-
// use source twice to match GNU's error message
343-
MvError::SameFile(source.quote().to_string(), source.quote().to_string()).into(),
344-
);
345-
}
346-
347339
let target_is_dir = target.is_dir();
348340
let source_is_dir = source.is_dir();
349341

tests/by-util/test_mv.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -402,23 +402,7 @@ fn test_mv_same_file() {
402402
ucmd.arg(file_a)
403403
.arg(file_a)
404404
.fails()
405-
.stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n"));
406-
}
407-
408-
#[test]
409-
fn test_mv_file_to_same_dir() {
410-
let (at, mut ucmd) = at_and_ucmd!();
411-
let file = "a";
412-
let dir = "dir";
413-
let path = &format!("{dir}/{file}");
414-
415-
at.mkdir(dir);
416-
at.touch(path);
417-
418-
ucmd.arg(path)
419-
.arg(dir)
420-
.fails()
421-
.stderr_is(format!("mv: '{path}' and '{path}' are the same file\n"));
405+
.stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n",));
422406
}
423407

424408
#[test]

0 commit comments

Comments
 (0)