]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: fix --backup with subdirectories
authorPádraig Brady <P@draigBrady.com>
Mon, 3 Apr 2023 17:12:33 +0000 (18:12 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 4 Apr 2023 11:00:11 +0000 (12:00 +0100)
* gnulib: Reference the latest gnulib including the
fix to the backupfile module in commit 94496522.
* tests/cp/backup-dir.sh: Add a test to ensure
we rename appropriately when backing up through subdirs.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/62607

NEWS
gnulib
tests/cp/backup-dir.sh

diff --git a/NEWS b/NEWS
index f53adab6fc3c13a260dfcc827b5eed7cd338ccc3..8f947faed4186d683ce61082b681743da5fdd454 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,12 +4,17 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
-  cp --relink=auto (the default), mv, and install
+  cp --reflink=auto (the default), mv, and install
   will again fall back to a standard copy in more cases.
   Previously copies could fail with permission errors on
   more restricted systems like android or containers etc.
   [bug introduced in coreutils-9.2]
 
+  cp --recursive --backup will again operate correctly.
+  Previousy it may have issued "File exists" errors when
+  it failed to appropriately rename files being replaced.
+  [bug introduced in coreutils-9.2]
+
   date --file and dircolors will now diagnose a failure to read a file.
   Previously they would have silently ignored the failure.
   [This bug was present in "the beginning".]
diff --git a/gnulib b/gnulib
index f17d397771164c1b0f77fea8fb0abdc99cf4a3e1..94496522f25f19673acb759409d4cdcc6038daee 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit f17d397771164c1b0f77fea8fb0abdc99cf4a3e1
+Subproject commit 94496522f25f19673acb759409d4cdcc6038daee
index 6573d58e07b6a110e24138c10a2b93ceec77a018..5c17498cf4d2981683bec769d4e7f6430dbed631 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Ensure that cp -b doesn't back up directories.
+# Ensure that cp -b handles directories appropriately
 
 # Copyright (C) 2006-2023 Free Software Foundation, Inc.
 
@@ -29,4 +29,10 @@ cp -ab x y || fail=1
 test -d y/x || fail=1
 test -d y/x~ && fail=1
 
+# Bug 62607.
+# This would fail to backup using rename, and thus fail to replace the file
+mkdir -p {src,dst}/foo || framework_failure_
+touch {src,dst}/foo/bar || framework_failure_
+cp --recursive --backup src/* dst || fail=1
+
 Exit $fail