From: Jim Meyering Date: Mon, 4 Sep 2000 14:45:42 +0000 (+0000) Subject: factor out backup/same test, put it after if-else. X-Git-Tag: FILEUTILS-4_0z~50 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=616d9920c019425e77ebd5d075e0ce416fa210e1;p=thirdparty%2Fcoreutils.git factor out backup/same test, put it after if-else. --- diff --git a/src/copy.c b/src/copy.c index 611583beab..8b238680a6 100644 --- a/src/copy.c +++ b/src/copy.c @@ -413,19 +413,6 @@ same_file_ok (const char *src_path, const struct stat *src_sb, { same_link = same; - /* The backup code ensures there's a copy, so it's ok to remove - any destination file. But there's one exception: when both - source and destination are the same directory entry. In that - case, moving the destination file aside (in making the backup) - would also rename the source file and result in an error. */ - if (x->backup_type != none) - { - if (!same_link) - return 1; - - return ! same_name (src_path, dst_path); - } - /* If both the source and destination files are symlinks (and we'll know this here IFF preserving symlinks (aka xstat == lstat), then it's ok. */ @@ -459,20 +446,19 @@ same_file_ok (const char *src_path, const struct stat *src_sb, if (S_ISLNK (src_sb_link->st_mode) && S_ISLNK (dst_sb_link->st_mode) && x->unlink_dest_before_opening) return 1; + } - /* FIXME: factor this code and above */ - /* The backup code ensures there's a copy, so it's ok to remove - any destination file. But there's one exception: when both - source and destination are the same directory entry. In that - case, moving the destination file aside (in making the backup) - would also rename the source file and result in an error. */ - if (x->backup_type != none) - { - if (!same_link) - return 1; + /* The backup code ensures there's a copy, so it's ok to remove + any destination file. But there's one exception: when both + source and destination are the same directory entry. In that + case, moving the destination file aside (in making the backup) + would also rename the source file and result in an error. */ + if (x->backup_type != none) + { + if (!same_link) + return 1; - return ! same_name (src_path, dst_path); - } + return ! same_name (src_path, dst_path); } #if 0