Skip to content

Commit

Permalink
Merge pull request #5701 from sylvestre/debug
Browse files Browse the repository at this point in the history
cp: debug with --update=none should show 'skipped'
  • Loading branch information
cakebaker committed Dec 24, 2023
2 parents 8ede675 + 8685e05 commit 4d05f20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,13 @@ fn copy_file(
symlinked_files,
)?;
}
update_control::UpdateMode::ReplaceNone => return Ok(()),
update_control::UpdateMode::ReplaceNone => {
if options.debug {
println!("skipped {}", dest.quote());
}

return Ok(());
}
update_control::UpdateMode::ReplaceIfOlder => {
let dest_metadata = fs::symlink_metadata(dest)?;

Expand Down
15 changes: 15 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3367,6 +3367,21 @@ fn test_cp_debug_sparse_reflink() {
}
}

#[test]
fn test_cp_debug_no_update() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("a");
at.touch("b");
ts.ucmd()
.arg("--debug")
.arg("--update=none")
.arg("a")
.arg("b")
.succeeds()
.stdout_contains("skipped 'b'");
}

#[test]
#[cfg(target_os = "linux")]
fn test_cp_debug_sparse_always() {
Expand Down

0 comments on commit 4d05f20

Please sign in to comment.