coreutils
coreutils copied to clipboard
cp: correctly copy ancestor dirs in --parents mode
Fix a bug where cp failed to copy ancestor directories when using
the --parents option. For example, before this commit:
$ mkdir -p a/b/c d
$ cp --parents a/b/c d
$ find d
d
d/c
After this commit
$ mkdir -p a/b/c d
$ cp --parents a/b/c d
$ find d
d
d/a
d/a/b
d/a/b/c
This commit also adds the correct messages for --verbose mode:
$ cp -r --parents --verbose a/b/c d
a -> d/a
a/b -> d/a/b
'a/b/c' -> 'd/a/b/c'
Fixes #3332.
Okay there are some WIndows issues I need to resolve, but there is another failure reported in the GNU test suite that I want to explain.
The test case tests/cp/src-base-dot.sh claims to verify that
mkdir x y
cd y
cp --verbose -ab ../x/. .
succeeds, prints nothing to stdout, and is a no-op. However, it doesn't actually verify that the operation is a no-op, it only verifies that --verbose prints nothing. It just assumes that the directory x does not get copied into the directory y.
On the main branch, uutils cp will cause the directory x to be copied into the directory y, and nothing will be printed by --verbose (this is incorrect behavior). On this new branch, uutils cp will cause the directory x to be copied into the directory y but now --verbose will print the message ../x/. -> ./x (this is still incorrect behavior).
So the tests/cp/src-base-dot.sh test case was incorrectly passing on the main branch, and now it is correctly marked as a failure.
nice:
Warning: Congrats! The gnu test tests/cp/cp-parents is no longer ERROR!
Did you see
Error: GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?
Did you see
Error: GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?
Yes, it is an expected failure. The explanation is in my comment above https://github.com/uutils/coreutils/pull/3894#issuecomment-1236041009 and I created a new issue for that here https://github.com/uutils/coreutils/issues/3897
sorry about that :(
Seems that it broke a few tests ?
Error: GNU test failed: tests/cp/cp-i. tests/cp/cp-i is passing on 'main'. Maybe you have to rebase?
Error: GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?
tests/cp/src-base-dot is an expected new failure, see my comments above. However, tests/cp/cp-i does seem to be an unexpected new failure, so I'll fix that.
I'm going to mark this as a draft pull request because there's still some weird behaviors of GNU cp that I haven't quite figure out yet. Specifically, I need to figure out how to get the quoting behavior for cp -v to work in both the cp-i.sh test case and the cp-parents.sh case.
Okay, this is ready for review again.
I'm going to close this and come back with a pull request that doesn't attempt to implement the --verbose behavior.