From 9877085702d359dd04cade165231fc2fce64178e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 2 Dec 2024 20:39:39 +0100 Subject: [PATCH] Revert "mv: show "same file" error for `mv d/f d`" --- src/uu/mv/src/mv.rs | 8 -------- tests/by-util/test_mv.rs | 18 +----------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 20a22043c..9d8452b1e 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -314,7 +314,6 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> ) .into()); } - if source.symlink_metadata().is_err() { return Err(if path_ends_with_terminator(source) { MvError::CannotStatNotADirectory(source.quote().to_string()).into() @@ -337,13 +336,6 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> } } - if source.parent() == Some(target) { - return Err( - // use source twice to match GNU's error message - MvError::SameFile(source.quote().to_string(), source.quote().to_string()).into(), - ); - } - let target_is_dir = target.is_dir(); let source_is_dir = source.is_dir(); diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 562e24754..6ab989ee4 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -402,23 +402,7 @@ fn test_mv_same_file() { ucmd.arg(file_a) .arg(file_a) .fails() - .stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n")); -} - -#[test] -fn test_mv_file_to_same_dir() { - let (at, mut ucmd) = at_and_ucmd!(); - let file = "a"; - let dir = "dir"; - let path = &format!("{dir}/{file}"); - - at.mkdir(dir); - at.touch(path); - - ucmd.arg(path) - .arg(dir) - .fails() - .stderr_is(format!("mv: '{path}' and '{path}' are the same file\n")); + .stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n",)); } #[test]