Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp: correctly copy ancestor dirs in --parents mode #4071

Merged
merged 3 commits into from
Oct 23, 2022

Conversation

jfinkels
Copy link
Collaborator

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 -a --parents a/b/c d
$ find d
d
d/c

After this commit

$ mkdir -p a/b/c d
$ cp -a --parents a/b/c d
$ find d
d
d/a
d/a/b
 d/a/b/c

Partially resolves issue #3332.

(My first attempt was in #3894.)

Before this commit, `cp -a` would terminate with a non-zero status
code on Windows because there are no extended attributes (xattr) to
copy. However, the GNU documentation for cp states

> Try to preserve SELinux security context and extended attributes
> (xattr), but ignore any failure to do that and print no
> corresponding diagnostic.

so it seems reasonable to do nothing instead of exiting with an error
in this case.
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 uutils#3332.
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/cp-parents. tests/cp/cp-parents is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/cp/cp-parents is no longer ERROR!

@sylvestre
Copy link
Contributor

GNU testsuite comparison:

GNU test failed: tests/cp/cp-parents. tests/cp/cp-parents is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/cp/cp-parents is no longer ERROR!

Not sure what is happening here :)

@sylvestre sylvestre merged commit e031e5f into uutils:main Oct 23, 2022
@jfinkels
Copy link
Collaborator Author

GNU test failed: tests/cp/cp-parents. tests/cp/cp-parents is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/cp/cp-parents is no longer ERROR!

I think it is trying to say that the test on the main branch reported an ERROR, but now it reports a FAIL. (The wording of the comment does not quite match the intent.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants