Added ability to limit certain chmod directives to just dirs or files.
[rsync/rsync-patches.git] / date-only.diff
CommitLineData
07b2cce7
MP
1Greetings, and thanks for all of your work on the wonderful rsync!
2
3I recently had the need to transfer files only with different mod
4dates (and to *not* transfer them based on file size differences).
5This is because I'm backing up files remotely on an untrusted machine,
6so I'm encrypting them with gpg before transfer. I discovered that
7rsync didn't already have a --date-only flag, so I added one and am
8enclosing the diffs in case you (as I hope) decide to include this
9option in future releases.
10
11Again, thanks!
12
13Best Regards,
14Jeremy Bornstein
c66bc26c
WD
15
16[Patched update to have context and apply to latest CVS source.]
17
18--- generator.c 10 Feb 2004 22:56:16 -0000 1.75
19+++ generator.c 24 Feb 2004 19:17:31 -0000
20@@ -43,11 +43,14 @@
21 extern int always_checksum;
22 extern char *compare_dest;
23 extern int link_dest;
24+extern int date_only;
25
26
27 /* choose whether to skip a particular file */
28 static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st)
29 {
30+ if (date_only)
31+ return cmp_modtime(st->st_mtime,file->modtime) == 0;
32 if (st->st_size != file->length) {
33 return 0;
34 }
35--- options.c 22 Feb 2004 08:56:43 -0000 1.139
36+++ options.c 24 Feb 2004 19:17:31 -0000
37@@ -80,6 +80,7 @@
38 int safe_symlinks = 0;
39 int copy_unsafe_links = 0;
40 int size_only = 0;
41+int date_only = 0;
42 int bwlimit = 0;
43 int delete_after = 0;
44 int only_existing = 0;
45@@ -260,6 +261,7 @@
46 rprintf(F," --timeout=TIME set I/O timeout in seconds\n");
47 rprintf(F," -I, --ignore-times turn off mod time & file size quick check\n");
48 rprintf(F," --size-only ignore mod time for quick check (use size)\n");
49+ rprintf(F," --date-only ignore size for quick check (use mod time)\n");
50 rprintf(F," --modify-window=NUM compare mod times with reduced accuracy\n");
51 rprintf(F," -T --temp-dir=DIR create temporary files in directory DIR\n");
52 rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
53@@ -314,6 +316,7 @@
54 {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
55 {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
56 {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
57+ {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 },
58 {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
59 {"one-file-system", 'x', POPT_ARG_NONE, &one_file_system, 0, 0, 0 },
60 {"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0, 0 },
61@@ -886,6 +889,9 @@
62
63 if (size_only)
64 args[ac++] = "--size-only";
65+
66+ if (date_only)
67+ args[ac++] = "--date-only";
68
69 if (modify_window_set) {
70 if (asprintf(&arg, "--modify-window=%d", modify_window) < 0)
71--- rsync.1 2 Feb 2004 18:23:09 -0000 1.163
72+++ rsync.1 24 Feb 2004 19:17:32 -0000
73@@ -357,6 +357,7 @@
74 --timeout=TIME set I/O timeout in seconds
75 -I, --ignore-times turn off mod time & file size quick check
76 --size-only ignore mod time for quick check (use size)
77+ --date-only ignore size for quick check (use mod time)
78 --modify-window=NUM compare mod times with reduced accuracy
79 -T --temp-dir=DIR create temporary files in directory DIR
80 --compare-dest=DIR also compare received files relative to DIR
81@@ -435,6 +436,13 @@
82 regardless of timestamp\&. This is useful when starting to use rsync
83 after using another mirroring system which may not preserve timestamps
84 exactly\&.
85+.IP
86+.IP "\fB--date-only\fP"
87+Normally rsync will skip any files that are
88+already the same size and have the same modification time-stamp\&. With the
89+--date-only option, files will be skipped if they have the same
90+timestamp, regardless of size\&. This may be useful when the remote
91+files have passed through a size-changing filter, e\&.g\&. for encryption\&.
92 .IP
93 .IP "\fB--modify-window\fP"
94 When comparing two timestamps rsync treats
95--- rsync.yo 2 Feb 2004 18:23:09 -0000 1.147
96+++ rsync.yo 24 Feb 2004 19:17:33 -0000
97@@ -320,6 +320,7 @@
98 --timeout=TIME set I/O timeout in seconds
99 -I, --ignore-times turn off mod time & file size quick check
100 --size-only ignore mod time for quick check (use size)
101+ --date-only ignore size for quick check (use mod time)
102 --modify-window=NUM compare mod times with reduced accuracy
103 -T --temp-dir=DIR create temporary files in directory DIR
104 --compare-dest=DIR also compare received files relative to DIR
105@@ -390,6 +391,12 @@
106 regardless of timestamp. This is useful when starting to use rsync
107 after using another mirroring system which may not preserve timestamps
108 exactly.
109+
110+dit(bf(--date-only)) Normally rsync will skip any files that are
111+already the same size and have the same modification time-stamp. With the
112+--date-only option, files will be skipped if they have the same
113+timestamp, regardless of size. This may be useful when the remote
114+files have passed through a size-changing filter, e.g. for encryption.
115
116 dit(bf(--modify-window)) When comparing two timestamps rsync treats
117 the timestamps as being equal if they are within the value of