mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #6496 from djedi23/6267-cp-preserved-hardlinks-are-not-reported-in--verbose
cp: fix preserved hardlinks are not reported in --verbose
This commit is contained in:
commit
e08c43ade2
2 changed files with 34 additions and 4 deletions
|
@ -2108,6 +2108,10 @@ fn copy_file(
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.verbose {
|
||||||
|
print_verbose_output(options.parents, progress_bar, source, dest);
|
||||||
|
}
|
||||||
|
|
||||||
if options.preserve_hard_links() {
|
if options.preserve_hard_links() {
|
||||||
// if we encounter a matching device/inode pair in the source tree
|
// if we encounter a matching device/inode pair in the source tree
|
||||||
// we can arrange to create a hard link between the corresponding names
|
// we can arrange to create a hard link between the corresponding names
|
||||||
|
@ -2121,10 +2125,6 @@ fn copy_file(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.verbose {
|
|
||||||
print_verbose_output(options.parents, progress_bar, source, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the context upfront before canonicalizing the path
|
// Calculate the context upfront before canonicalizing the path
|
||||||
let context = context_for(source, dest);
|
let context = context_for(source, dest);
|
||||||
let context = context.as_str();
|
let context = context.as_str();
|
||||||
|
|
|
@ -608,6 +608,36 @@ fn test_cp_arg_link_with_same_file() {
|
||||||
assert!(at.file_exists(file));
|
assert!(at.file_exists(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn test_cp_verbose_preserved_link_to_dir() {
|
||||||
|
use std::os::linux::fs::MetadataExt;
|
||||||
|
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let file = "file";
|
||||||
|
let hardlink = "hardlink";
|
||||||
|
let dir = "dir";
|
||||||
|
let dst_file = "dir/file";
|
||||||
|
let dst_hardlink = "dir/hardlink";
|
||||||
|
|
||||||
|
at.touch(file);
|
||||||
|
at.hard_link(file, hardlink);
|
||||||
|
at.mkdir(dir);
|
||||||
|
|
||||||
|
ucmd.args(&["-d", "--verbose", file, hardlink, dir])
|
||||||
|
.succeeds()
|
||||||
|
.stdout_is("'file' -> 'dir/file'\n'hardlink' -> 'dir/hardlink'\n");
|
||||||
|
|
||||||
|
assert!(at.file_exists(dst_file));
|
||||||
|
assert!(at.file_exists(dst_hardlink));
|
||||||
|
assert_eq!(at.metadata(dst_file).st_nlink(), 2);
|
||||||
|
assert_eq!(at.metadata(dst_hardlink).st_nlink(), 2);
|
||||||
|
assert_eq!(
|
||||||
|
at.metadata(dst_file).st_ino(),
|
||||||
|
at.metadata(dst_hardlink).st_ino()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cp_arg_symlink() {
|
fn test_cp_arg_symlink() {
|
||||||
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