064014e186416b3a613459e083e0ac7525df49f7
[rsync/rsync-patches.git] / dir-times.diff
1 --- options.c   27 May 2004 21:51:53 -0000      1.153
2 +++ options.c   4 Jun 2004 05:26:50 -0000
3 @@ -46,6 +46,7 @@ int preserve_devices = 0;
4  int preserve_uid = 0;
5  int preserve_gid = 0;
6  int preserve_times = 0;
7 +int preserve_dir_times = 0;
8  int update_only = 0;
9  int cvs_exclude = 0;
10  int dry_run = 0;
11 @@ -241,7 +242,8 @@ void usage(enum logcode F)
12    rprintf(F," -o, --owner                 preserve owner (root only)\n");
13    rprintf(F," -g, --group                 preserve group\n");
14    rprintf(F," -D, --devices               preserve devices (root only)\n");
15 -  rprintf(F," -t, --times                 preserve times\n");
16 +  rprintf(F," -t, --times                 preserve times on non-directories\n");
17 +  rprintf(F," -d, --dir-times             preserve times on directories\n");
18    rprintf(F," -S, --sparse                handle sparse files efficiently\n");
19    rprintf(F," -n, --dry-run               show what would have been transferred\n");
20    rprintf(F," -W, --whole-file            copy whole files, no incremental checks\n");
21 @@ -348,6 +350,7 @@ static struct poptOption long_options[] 
22    {"group",           'g', POPT_ARG_NONE,   &preserve_gid, 0, 0, 0 },
23    {"devices",         'D', POPT_ARG_NONE,   &preserve_devices, 0, 0, 0 },
24    {"times",           't', POPT_ARG_NONE,   &preserve_times, 0, 0, 0 },
25 +  {"dir-times",       'd', POPT_ARG_NONE,   &preserve_dir_times, 0, 0, 0 },
26    {"checksum",        'c', POPT_ARG_NONE,   &always_checksum, 0, 0, 0 },
27    {"verbose",         'v', POPT_ARG_NONE,   0,               'v', 0, 0 },
28    {"quiet",           'q', POPT_ARG_NONE,   0,               'q', 0, 0 },
29 @@ -835,6 +838,8 @@ void server_options(char **args,int *arg
30                 argstr[x++] = 'D';
31         if (preserve_times)
32                 argstr[x++] = 't';
33 +       if (preserve_dir_times && am_sender)
34 +               argstr[x++] = 'd';
35         if (preserve_perms)
36                 argstr[x++] = 'p';
37         if (recurse)
38 --- rsync.c     21 May 2004 08:43:03 -0000      1.140
39 +++ rsync.c     4 Jun 2004 05:26:50 -0000
40 @@ -25,6 +25,7 @@
41  extern int verbose;
42  extern int dry_run;
43  extern int preserve_times;
44 +extern int preserve_dir_times;
45  extern int am_root;
46  extern int am_sender;
47  extern int am_generator;
48 @@ -140,15 +141,16 @@ int set_perms(char *fname,struct file_st
49                 st = &st2;
50         }
51  
52 -       if (!preserve_times || S_ISLNK(st->st_mode)
53 -           || (make_backups && !backup_dir && S_ISDIR(st->st_mode)))
54 -               flags |= PERMS_SKIP_MTIME;
55 +       if (S_ISDIR(st->st_mode)) {
56 +               if (!preserve_dir_times || (make_backups && !backup_dir))
57 +                       flags |= PERMS_SKIP_MTIME;
58 +       } else {
59 +               if (!preserve_times || S_ISLNK(st->st_mode))
60 +                       flags |= PERMS_SKIP_MTIME;
61 +       }
62         if (!(flags & PERMS_SKIP_MTIME)
63             && cmp_modtime(st->st_mtime, file->modtime) != 0) {
64 -               /* don't complain about not setting times on directories
65 -                * because some filesystems can't do it */
66 -               if (set_modtime(fname,file->modtime) != 0 &&
67 -                   !S_ISDIR(st->st_mode)) {
68 +               if (set_modtime(fname,file->modtime) != 0) {
69                         rsyserr(FERROR, errno, "failed to set times on %s",
70                                 full_fname(fname));
71                         return 0;
72 --- rsync.yo    21 May 2004 09:44:32 -0000      1.170
73 +++ rsync.yo    4 Jun 2004 05:26:51 -0000
74 @@ -298,7 +298,8 @@ verb(
75   -o, --owner                 preserve owner (root only)
76   -g, --group                 preserve group
77   -D, --devices               preserve devices (root only)
78 - -t, --times                 preserve times
79 + -t, --times                 preserve times on non-directories
80 + -d, --dir-times             preserve times on directories
81   -S, --sparse                handle sparse files efficiently
82   -n, --dry-run               show what would have been transferred
83   -W, --whole-file            copy whole files, no incremental checks
84 @@ -539,14 +540,23 @@ dit(bf(-D, --devices)) This option cause
85  block device information to the remote system to recreate these
86  devices. This option is only available to the super-user.
87  
88 -dit(bf(-t, --times)) This tells rsync to transfer modification times along
89 -with the files and update them on the remote system.  Note that if this
90 +dit(bf(-t, --times)) This tells rsync to preserve modification times of
91 +non-directories transferred to the remote system.  Note that if this
92  option is not used, the optimization that excludes files that have not been
93  modified cannot be effective; in other words, a missing -t or -a will
94  cause the next transfer to behave as if it used -I, and all files will have
95  their checksums compared and show up in log messages even if they haven't
96  changed.
97  
98 +dit(bf(-d, --dir-times)) This tells rsync to preserve the modification
99 +times of directories transferred to the remote system.  On a modern
100 +rsync, these are left unpreserved by default to avoid causing problems
101 +for NFS.
102 +
103 +Note: when sending files to an older rsync, the --times option will
104 +imply --dir-times (if the option causes an error on the receiving
105 +system, omit it and use --times to preserve all file/directory times).
106 +
107  dit(bf(-n, --dry-run)) This tells rsync to not do any file transfers,
108  instead it will just report the actions it would have taken.
109  
110 --- testsuite/chgrp.test        21 May 2004 10:06:09 -0000      1.12
111 +++ testsuite/chgrp.test        4 Jun 2004 05:26:51 -0000
112 @@ -26,7 +26,7 @@ do
113  done
114  sleep 2
115  
116 -checkit "$RSYNC -rtgpvvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
117 +checkit "$RSYNC -rtdgpvvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
118  
119  # The script would have aborted on error, so getting here means we've won.
120  exit 0
121 --- testsuite/chown.test        18 May 2004 00:41:35 -0000      1.5
122 +++ testsuite/chown.test        4 Jun 2004 05:26:51 -0000
123 @@ -28,7 +28,7 @@ chown 5001 "$name2" || test_skipped "Can
124  chgrp 5002 "$name1" || test_skipped "Can't chgrp (probably need root)"
125  chgrp 5003 "$name2" || test_skipped "Can't chgrp (probably need root)"
126  
127 -checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
128 +checkit "$RSYNC -adHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
129  
130  # The script would have aborted on error, so getting here means we've won.
131  exit 0
132 --- testsuite/daemon-gzip-download.test 18 May 2004 00:41:51 -0000      1.7
133 +++ testsuite/daemon-gzip-download.test 4 Jun 2004 05:26:51 -0000
134 @@ -29,9 +29,9 @@ export RSYNC_CONNECT_PROG
135  hands_setup
136  
137  # Build chkdir with a normal rsync and an --exclude.
138 -$RSYNC -av --exclude=foobar.baz "$fromdir/" "$chkdir/"
139 +$RSYNC -adv --exclude=foobar.baz "$fromdir/" "$chkdir/"
140  
141 -checkit "$RSYNC -avvvvz localhost::test-from/ \"$todir/\"" "$chkdir" "$todir"
142 +checkit "$RSYNC -advvvvz localhost::test-from/ \"$todir/\"" "$chkdir" "$todir"
143  
144  # The script would have aborted on error, so getting here means we've won.
145  exit 0
146 --- testsuite/daemon-gzip-upload.test   18 May 2004 00:41:51 -0000      1.7
147 +++ testsuite/daemon-gzip-upload.test   4 Jun 2004 05:26:51 -0000
148 @@ -23,9 +23,9 @@ export RSYNC_CONNECT_PROG
149  hands_setup
150  
151  # Build chkdir with a normal rsync and an --exclude.
152 -$RSYNC -av --exclude=foobar.baz "$fromdir/" "$chkdir/"
153 +$RSYNC -adv --exclude=foobar.baz "$fromdir/" "$chkdir/"
154  
155 -checkit "$RSYNC -avvvvz \"$fromdir/\" localhost::test-to/" "$chkdir" "$todir"
156 +checkit "$RSYNC -advvvvz \"$fromdir/\" localhost::test-to/" "$chkdir" "$todir"
157  
158  # The script would have aborted on error, so getting here means we've won.
159  exit 0
160 --- testsuite/devices.test      18 May 2004 00:41:35 -0000      1.8
161 +++ testsuite/devices.test      4 Jun 2004 05:26:51 -0000
162 @@ -29,7 +29,7 @@ mknod "$fromdir/block" b 42 69 || test_s
163  mknod "$fromdir/block2" b 42 73 || test_skipped "Can't create block device node unless root"
164  mknod "$fromdir/block3" b 105 73 || test_skipped "Can't create block device node unless root"
165  
166 -checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
167 +checkit "$RSYNC -adHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
168  
169  # The script would have aborted on error, so getting here means we've won.
170  exit 0
171 --- testsuite/duplicates.test   18 May 2004 00:41:35 -0000      1.10
172 +++ testsuite/duplicates.test   4 Jun 2004 05:26:51 -0000
173 @@ -33,7 +33,7 @@ ln -s "$name1" "$name2" || fail "can't c
174  
175  outfile="$scratchdir/rsync.out"
176  
177 -checkit "$RSYNC -avv \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
178 +checkit "$RSYNC -advv \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
179      | tee "$outfile"
180  
181  # Make sure each file was only copied once...
182 --- testsuite/exclude.test      24 May 2004 00:16:07 -0000      1.8
183 +++ testsuite/exclude.test      4 Jun 2004 05:26:51 -0000
184 @@ -66,7 +66,7 @@ EOF
185  
186  # Create the chk dir with what we expect to be excluded
187  
188 -checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
189 +checkit "$RSYNC -advv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
190  
191  sleep 1 # Ensures that the rm commands will tweak the directory times.
192  
193 @@ -78,11 +78,11 @@ rm "$chkdir"/mid/for/foo/extra
194  
195  # Un-tweak the directory times in our first (weak) exclude test (though
196  # it's a good test of the --existing option).
197 -$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
198 +$RSYNC -adv --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
199  
200  # Now, test if rsync excludes the same files.
201  
202 -checkit "$RSYNC -avv --exclude-from=\"$excl\" \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
203 +checkit "$RSYNC -advv --exclude-from=\"$excl\" \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
204  
205  # Modify the chk dir by removing cvs-ignored files and then tweaking the dir times.
206  
207 @@ -92,12 +92,12 @@ rm "$chkdir"/bar/down/to/foo/*.junk
208  rm "$chkdir"/bar/down/to/home-cvs-exclude
209  rm "$chkdir"/mid/one-in-one-out
210  
211 -$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
212 +$RSYNC -adv --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
213  
214  # Now, test if rsync excludes the same files, this time with --cvs-exclude
215  # and --delete-excluded.
216  
217 -checkit "$RSYNC -avvC --exclude-from=\"$excl\" \
218 +checkit "$RSYNC -advvC --exclude-from=\"$excl\" \
219      --delete-excluded \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
220  
221  # The script would have aborted on error, so getting here means we've won.
222 --- testsuite/hands.test        18 May 2004 00:41:46 -0000      1.13
223 +++ testsuite/hands.test        4 Jun 2004 05:26:51 -0000
224 @@ -11,19 +11,19 @@ hands_setup
225  
226  # Main script starts here
227  
228 -runtest "basic operation" 'checkit "$RSYNC -av \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
229 +runtest "basic operation" 'checkit "$RSYNC -adv \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
230  
231  ln "$fromdir/filelist" "$fromdir/dir"
232 -runtest "hard links" 'checkit "$RSYNC -avH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
233 +runtest "hard links" 'checkit "$RSYNC -advH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
234  
235  rm "$todir/text"
236 -runtest "one file" 'checkit "$RSYNC -avH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
237 +runtest "one file" 'checkit "$RSYNC -advH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
238  
239  echo "extra line" >> "$todir/text"
240 -runtest "extra data" 'checkit "$RSYNC -avH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
241 +runtest "extra data" 'checkit "$RSYNC -advH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
242  
243  cp "$fromdir/text" "$todir/ThisShouldGo"
244 -runtest " --delete" 'checkit "$RSYNC --delete -avH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
245 +runtest " --delete" 'checkit "$RSYNC --delete -advH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"'
246  
247  # The script would have aborted on error, so getting here means we've won.
248  exit 0
249 --- testsuite/hardlinks.test    18 May 2004 00:41:40 -0000      1.5
250 +++ testsuite/hardlinks.test    4 Jun 2004 05:26:51 -0000
251 @@ -31,7 +31,7 @@ ln "$name1" "$name2" || fail "Can't crea
252  ln "$name2" "$name3" || fail "Can't create hardlink"
253  cp "$name2" "$name4" || fail "Can't copy file"
254  
255 -checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
256 +checkit "$RSYNC -adHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
257  
258  # The script would have aborted on error, so getting here means we've won.
259  exit 0
260 --- testsuite/longdir.test      18 May 2004 09:47:42 -0000      1.11
261 +++ testsuite/longdir.test      4 Jun 2004 05:26:51 -0000
262 @@ -18,7 +18,7 @@ makepath "$longdir" || test_skipped "una
263  touch "$longdir/1" || test_skipped "unable to create files in long directory"
264  date > "$longdir/1"
265  ls -la / > "$longdir/2"
266 -checkit "$RSYNC --delete -avH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"
267 +checkit "$RSYNC --delete -advH \"$fromdir/\" \"$todir\"" "$fromdir/" "$todir"
268  
269  # The script would have aborted on error, so getting here means we've won.
270  exit 0
271 --- testsuite/merge.test        18 May 2004 00:41:38 -0000      1.6
272 +++ testsuite/merge.test        4 Jun 2004 05:26:51 -0000
273 @@ -40,9 +40,9 @@ cp -p "$from2dir"/sub1/uno "$from3dir"/s
274  cp -p "$from3dir"/sub2/subby "$chkdir"/sub2
275  
276  # Get rid of any directory-time differences
277 -$RSYNC -av --existing --include='*/' --exclude='*' "$from1dir/" "$from2dir/" "$from3dir/" "$chkdir/"
278 +$RSYNC -adv --existing --include='*/' --exclude='*' "$from1dir/" "$from2dir/" "$from3dir/" "$chkdir/"
279  
280 -checkit "$RSYNC -aHvv \"$from1dir/\" \"$from2dir/\" \"$from3dir/\" \"$todir/\"" "$chkdir" "$todir"
281 +checkit "$RSYNC -adHvv \"$from1dir/\" \"$from2dir/\" \"$from3dir/\" \"$todir/\"" "$chkdir" "$todir"
282  
283  # The script would have aborted on error, so getting here means we've won.
284  exit 0
285 --- testsuite/ssh-basic.test    18 May 2004 00:41:46 -0000      1.7
286 +++ testsuite/ssh-basic.test    4 Jun 2004 05:26:51 -0000
287 @@ -28,7 +28,7 @@ fi
288  # nothing to do.
289  hands_setup
290  
291 -runtest "ssh: basic test" 'checkit "$RSYNC -avH -e ssh --rsync-path=$RSYNC \"$fromdir/\" \"localhost:$todir\"" "$fromdir/" "$todir"'
292 +runtest "ssh: basic test" 'checkit "$RSYNC -advH -e ssh --rsync-path=$RSYNC \"$fromdir/\" \"localhost:$todir\"" "$fromdir/" "$todir"'
293  
294  # Added by Steve Bonds Feb 2 2003
295  # I assumed that "F1" was intended to hold a single file for testing if
296 @@ -40,4 +40,4 @@ F1=`ls "$todir" | head -5 | tail -1`
297  
298  mv "$todir/$F1" "$todir/ThisShouldGo"
299  
300 -runtest "ssh: renamed file" 'checkit "$RSYNC --delete -avH -e ssh --rsync-path=$RSYNC \"$fromdir/\" \"localhost:$todir\"" "$fromdir/" "$todir"'
301 +runtest "ssh: renamed file" 'checkit "$RSYNC --delete -advH -e ssh --rsync-path=$RSYNC \"$fromdir/\" \"localhost:$todir\"" "$fromdir/" "$todir"'
302 --- testsuite/unsafe-links.test 18 May 2004 00:41:43 -0000      1.7
303 +++ testsuite/unsafe-links.test 4 Jun 2004 05:26:51 -0000
304 @@ -35,33 +35,33 @@ ln -s ../../unsafe/unsafefile "from/safe
305  set -x
306  
307  echo "rsync with relative path and just -a";
308 -$RSYNC -avv from/safe/ to
309 +$RSYNC -advv from/safe/ to
310  test_symlink to/links/file1
311  test_symlink to/links/file2
312  test_symlink to/links/unsafefile
313  
314  echo "rsync with relative path and -a --copy-links"
315 -$RSYNC -avv --copy-links from/safe/ to
316 +$RSYNC -advv --copy-links from/safe/ to
317  test_regular to/links/file1
318  test_regular to/links/file2
319  test_regular to/links/unsafefile
320  
321  echo "rsync with relative path and --copy-unsafe-links";
322 -$RSYNC -avv --copy-unsafe-links from/safe/ to
323 +$RSYNC -advv --copy-unsafe-links from/safe/ to
324  test_symlink to/links/file1
325  test_symlink to/links/file2
326  test_regular to/links/unsafefile
327  
328  rm -rf to
329  echo "rsync with relative2 path";
330 -(cd from; $RSYNC -avv --copy-unsafe-links safe/ ../to)
331 +(cd from; $RSYNC -advv --copy-unsafe-links safe/ ../to)
332  test_symlink to/links/file1
333  test_symlink to/links/file2
334  test_regular to/links/unsafefile
335  
336  rm -rf to
337  echo "rsync with absolute path";
338 -$RSYNC -avv --copy-unsafe-links `pwd`/from/safe/ to
339 +$RSYNC -advv --copy-unsafe-links `pwd`/from/safe/ to
340  test_symlink to/links/file1
341  test_symlink to/links/file2
342  test_regular to/links/unsafefile