diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-10-11 00:36:08 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-10-11 00:58:26 +0100 |
commit | 89906fd58100567b415f9c13d83121b988dfa325 (patch) | |
tree | 1ea7f048251c0cab5831e536b43c11afd8639c0a /Debian | |
parent | c826365c57b445c06ba4d5c5c90be24556eaa97b (diff) |
Dgit.pm: rename_link_xf: Always use cp
If we use mv on a symlink, it moves the link, not the file.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Dgit.pm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index 08a5b6c..19ea85b 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -445,8 +445,7 @@ sub rename_link_xf ($$$) { return 0; } $!=0; $?=0; - my @cmd = ($keeporig ? qw(cp) : qw(mv)); - push @cmd, (qw(--), $src, "$dst.tmp"); + my @cmd = (qw(cp --), $src, "$dst.tmp"); debugcmd '+',@cmd; if (system @cmd) { failedcmd_report_cmd undef, @cmd; @@ -454,12 +453,17 @@ sub rename_link_xf ($$$) { $! = -1; return 0; } - if (rename "$dst.tmp", $dst) { - return 1; - } else { - $@ = f_ "finally install file after mv: %S", $!; + if (!rename "$dst.tmp", $dst) { + $@ = f_ "finally install file after cp: %S", $!; return 0; } + if (!$keeporig) { + if (!unlink $src) { + $@ = f_ "delete old file after cp: %S", $!; + return 0; + } + } + return 1; } sub hashfile ($) { |