Made the hide/protect antonym rules better.
[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
a7219d20 18--- orig/generator.c 2005-02-03 02:04:20
58a9031f 19+++ generator.c 2004-11-11 22:15:27
ac23c334 20@@ -43,6 +43,7 @@ extern int inplace;
58a9031f 21 extern int make_backups;
7628f156
WD
22 extern int csum_length;
23 extern int ignore_times;
c66bc26c 24+extern int date_only;
58a9031f
WD
25 extern int size_only;
26 extern OFF_T max_size;
7628f156 27 extern int io_timeout;
ac23c334 28@@ -81,6 +82,8 @@ static int unchanged_attrs(struct file_s
4c1f2ca5
WD
29 /* Perform our quick-check heuristic for determining if a file is unchanged. */
30 static int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
c66bc26c
WD
31 {
32+ if (date_only)
8cec1ead
WD
33+ return cmp_modtime(st->st_mtime, file->modtime) == 0;
34 if (st->st_size != file->length)
c66bc26c 35 return 0;
4c1f2ca5 36
a7219d20 37--- orig/options.c 2005-02-01 10:39:22
79f132a1
WD
38+++ options.c 2005-01-28 19:14:15
39@@ -88,6 +88,7 @@ int keep_partial = 0;
c66bc26c
WD
40 int safe_symlinks = 0;
41 int copy_unsafe_links = 0;
42 int size_only = 0;
43+int date_only = 0;
bad31232 44 int daemon_bwlimit = 0;
c66bc26c 45 int bwlimit = 0;
78114162 46 size_t bwlimit_writemax = 0;
79f132a1 47@@ -298,6 +299,7 @@ void usage(enum logcode F)
c66bc26c 48 rprintf(F," --timeout=TIME set I/O timeout in seconds\n");
79f132a1
WD
49 rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n");
50 rprintf(F," --size-only skip files that match in size\n");
51+ rprintf(F," --date-only skip files that match in mod-time\n");
52 rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n");
d4e89c6a 53 rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
c66bc26c 54 rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
79f132a1 55@@ -352,6 +354,7 @@ static struct poptOption long_options[]
ea238f1c 56 {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
c66bc26c
WD
57 {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
58 {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
59+ {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 },
60 {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
61 {"one-file-system", 'x', POPT_ARG_NONE, &one_file_system, 0, 0, 0 },
ac23c334 62 {"existing", 0, POPT_ARG_NONE, &only_existing, 0, 0, 0 },
a7219d20 63@@ -1247,6 +1250,9 @@ void server_options(char **args,int *arg
c66bc26c
WD
64 if (size_only)
65 args[ac++] = "--size-only";
78114162 66
c66bc26c
WD
67+ if (date_only)
68+ args[ac++] = "--date-only";
78114162 69+
c66bc26c
WD
70 if (modify_window_set) {
71 if (asprintf(&arg, "--modify-window=%d", modify_window) < 0)
78114162 72 goto oom;
a7219d20 73--- orig/rsync.yo 2005-02-01 10:39:23
79f132a1 74+++ rsync.yo 2005-01-28 19:14:37
a7219d20 75@@ -349,6 +349,7 @@ to the detailed description below for a
c66bc26c 76 --timeout=TIME set I/O timeout in seconds
79f132a1
WD
77 -I, --ignore-times don't skip files that match size and time
78 --size-only skip files that match in size
79+ --date-only skip files that match in mod-time
80 --modify-window=NUM compare mod-times with reduced accuracy
c66bc26c
WD
81 -T --temp-dir=DIR create temporary files in directory DIR
82 --compare-dest=DIR also compare received files relative to DIR
a7219d20 83@@ -434,6 +435,12 @@ regardless of timestamp. This is useful
c66bc26c
WD
84 after using another mirroring system which may not preserve timestamps
85 exactly.
78114162 86
c66bc26c
WD
87+dit(bf(--date-only)) 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.
78114162 92+
c66bc26c
WD
93 dit(bf(--modify-window)) When comparing two timestamps rsync treats
94 the timestamps as being equal if they are within the value of
78114162 95 modify_window. This is normally zero, but you may find it useful to