summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch')
-rw-r--r--meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch118
1 files changed, 118 insertions, 0 deletions
diff --git a/meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch b/meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch
new file mode 100644
index 0000000000..6fec683bc3
--- /dev/null
+++ b/meta/recipes-core/coreutils/coreutils-6.9/coreutils-6.9-cp-i-u.patch
@@ -0,0 +1,118 @@
1This patch was imported from the Fedora Core 8 coreutils-6.9-9 package.
2
3The package is stated as being Licensed as GPLv2+.
4
5Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
6
7----
8
9When "cp -i --update old new" would do nothing because "new" is
10newer than "old", cp would nonetheless prompt for whether it is
11ok to overwrite "new". Then, regardless of the response (because
12of the --update option), cp would do nothing.
13
14The following patch eliminates the unnecessary prompt in that case.
15
16diff --git a/src/copy.c b/src/copy.c
17index b7bf73b..0e549d2 100644
18--- a/src/copy.c
19+++ b/src/copy.c
20@@ -1210,6 +1210,30 @@ copy_internal (char const *src_name, char const *dst_name,
21 return false;
22 }
23
24+ if (!S_ISDIR (src_mode) && x->update)
25+ {
26+ /* When preserving time stamps (but not moving within a file
27+ system), don't worry if the destination time stamp is
28+ less than the source merely because of time stamp
29+ truncation. */
30+ int options = ((x->preserve_timestamps
31+ && ! (x->move_mode
32+ && dst_sb.st_dev == src_sb.st_dev))
33+ ? UTIMECMP_TRUNCATE_SOURCE
34+ : 0);
35+
36+ if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options))
37+ {
38+ /* We're using --update and the destination is not older
39+ than the source, so do not copy or move. Pretend the
40+ rename succeeded, so the caller (if it's mv) doesn't
41+ end up removing the source file. */
42+ if (rename_succeeded)
43+ *rename_succeeded = true;
44+ return true;
45+ }
46+ }
47+
48 /* When there is an existing destination file, we may end up
49 returning early, and hence not copying/moving the file.
50 This may be due to an interactive `negative' reply to the
51@@ -1302,30 +1326,6 @@ copy_internal (char const *src_name, char const *dst_name,
52 return false;
53 }
54 }
55-
56- if (x->update)
57- {
58- /* When preserving time stamps (but not moving within a file
59- system), don't worry if the destination time stamp is
60- less than the source merely because of time stamp
61- truncation. */
62- int options = ((x->preserve_timestamps
63- && ! (x->move_mode
64- && dst_sb.st_dev == src_sb.st_dev))
65- ? UTIMECMP_TRUNCATE_SOURCE
66- : 0);
67-
68- if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options))
69- {
70- /* We're using --update and the destination is not older
71- than the source, so do not copy or move. Pretend the
72- rename succeeded, so the caller (if it's mv) doesn't
73- end up removing the source file. */
74- if (rename_succeeded)
75- *rename_succeeded = true;
76- return true;
77- }
78- }
79 }
80
81 if (x->move_mode)
82diff --git a/tests/mv/update b/tests/mv/update
83index 0c06024..6c3d149 100755
84--- a/tests/mv/update
85+++ b/tests/mv/update
86@@ -1,7 +1,7 @@
87 #!/bin/sh
88 # make sure --update works as advertised
89
90-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
91+# Copyright (C) 2001, 2004, 2006-2007 Free Software Foundation, Inc.
92
93 # This program is free software; you can redistribute it and/or modify
94 # it under the terms of the GNU General Public License as published by
95@@ -46,11 +46,16 @@ fi
96
97 fail=0
98
99-for cp_or_mv in cp mv; do
100- # This is a no-op.
101- $cp_or_mv --update old new || fail=1
102- case "`cat new`" in new) ;; *) fail=1 ;; esac
103- case "`cat old`" in old) ;; *) fail=1 ;; esac
104+for interactive in '' -i; do
105+ for cp_or_mv in cp mv; do
106+ # This is a no-op, with no prompt.
107+ # With coreutils-6.9 and earlier, using --update with -i would
108+ # mistakenly elicit a prompt.
109+ $cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1
110+ test -s out && fail=1
111+ case "`cat new`" in new) ;; *) fail=1 ;; esac
112+ case "`cat old`" in old) ;; *) fail=1 ;; esac
113+ done
114 done
115
116 # This will actually perform the rename.
117--
1181.5.3.rc1.16.g9d6f