diff options
author | Jim Meyering <jim@meyering.net> | 2006-10-14 05:20:27 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-10-14 05:20:27 +0000 |
commit | 0dc7f789861bedfa74639b89be8c3c4e8b3b6490 (patch) | |
tree | a10e74951ace317aacfad47febcc83e566fa31d0 /src | |
parent | 779168820b3a002ead47e2ad79e15ab68018fc0b (diff) | |
download | coreutils-0dc7f789861bedfa74639b89be8c3c4e8b3b6490.tar.xz |
* NEWS: cp -r --backup dir1 dir2, would rename an existing dir1/dir2
to dir1/dir2~.
* src/copy.c (copy_internal): Although we do create a backup of each
destination directory when in move mode, don't do that when copying.
Reported by Peter Breitenlohner, in
<http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/8616>.
* tests/cp/backup-dir: New file. Test for the above.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/copy.c b/src/copy.c index 2a85578a6..2f03599e5 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1181,7 +1181,13 @@ copy_internal (char const *src_name, char const *dst_name, if (x->backup_type != no_backups /* Don't try to back up a destination if the last component of src_name is "." or "..". */ - && ! dot_or_dotdot (last_component (src_name))) + && ! dot_or_dotdot (last_component (src_name)) + /* Create a backup of each destination directory in move mode, + but not in copy mode. FIXME: it might make sense to add an + option to suppress backup creation also for move mode. + That would let one use mv to merge new content into an + existing hierarchy. */ + && (x->move_mode || ! S_ISDIR (dst_sb.st_mode))) { char *tmp_backup = find_backup_file_name (dst_name, x->backup_type); |