mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
mv --backup=simple a b on hard links should not fail
touch a ln a b ./target/debug/coreutils mv --backup=simple a b GNU: tests/mv/hard-4.sh
This commit is contained in:
parent
1b99376d95
commit
594f81a88a
2 changed files with 20 additions and 1 deletions
|
@ -255,7 +255,9 @@ fn handle_two_paths(source: &Path, target: &Path, b: &Behavior) -> UResult<()> {
|
||||||
return Err(MvError::NoSuchFile(source.quote().to_string()).into());
|
return Err(MvError::NoSuchFile(source.quote().to_string()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if source.eq(target) || are_hardlinks_to_same_file(source, target) {
|
if (source.eq(target) || are_hardlinks_to_same_file(source, target))
|
||||||
|
&& b.backup != BackupMode::SimpleBackup
|
||||||
|
{
|
||||||
if source.eq(Path::new(".")) || source.ends_with("/.") || source.is_file() {
|
if source.eq(Path::new(".")) || source.ends_with("/.") || source.is_file() {
|
||||||
return Err(
|
return Err(
|
||||||
MvError::SameFile(source.quote().to_string(), target.quote().to_string()).into(),
|
MvError::SameFile(source.quote().to_string(), target.quote().to_string()).into(),
|
||||||
|
|
|
@ -417,6 +417,23 @@ fn test_mv_same_hardlink() {
|
||||||
.stderr_is(format!("mv: '{file_a}' and '{file_b}' are the same file\n",));
|
.stderr_is(format!("mv: '{file_a}' and '{file_b}' are the same file\n",));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn test_mv_same_hardlink_backup_simple() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let file_a = "test_mv_same_file_a";
|
||||||
|
let file_b = "test_mv_same_file_b";
|
||||||
|
at.touch(file_a);
|
||||||
|
|
||||||
|
at.hard_link(file_a, file_b);
|
||||||
|
|
||||||
|
at.touch(file_a);
|
||||||
|
ucmd.arg(file_a)
|
||||||
|
.arg(file_b)
|
||||||
|
.arg("--backup=simple")
|
||||||
|
.succeeds();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mv_same_file_not_dot_dir() {
|
fn test_mv_same_file_not_dot_dir() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue