Updated patches to work with the current trunk.
[rsync/rsync-patches.git] / date-only.diff
CommitLineData
03019e41 1Jeremy Bornstein wrote:
07b2cce7
MP
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
03019e41 11To use this patch, run these commands for a successful build:
07b2cce7 12
03019e41
WD
13 patch -p1 <patches/date-only.diff
14 ./configure (optional if already run)
15 make
c66bc26c 16
cc3e685d 17diff --git a/generator.c b/generator.c
fc557362 18index 12007a1..a2519e6 100644
cc3e685d
WD
19--- a/generator.c
20+++ b/generator.c
fc557362 21@@ -64,6 +64,7 @@ extern int append_mode;
58a9031f 22 extern int make_backups;
7628f156
WD
23 extern int csum_length;
24 extern int ignore_times;
c66bc26c 25+extern int date_only;
58a9031f
WD
26 extern int size_only;
27 extern OFF_T max_size;
e0e47893 28 extern OFF_T min_size;
fc557362 29@@ -524,6 +525,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
4c1f2ca5 30 /* Perform our quick-check heuristic for determining if a file is unchanged. */
e0e47893 31 int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
c66bc26c
WD
32 {
33+ if (date_only)
5b775703 34+ return cmp_time(st->st_mtime, file->modtime) == 0;
1aa236e1
WD
35+
36 if (st->st_size != F_LENGTH(file))
c66bc26c 37 return 0;
4c1f2ca5 38
cc3e685d 39diff --git a/options.c b/options.c
fc557362 40index e7c6c61..b317903 100644
cc3e685d
WD
41--- a/options.c
42+++ b/options.c
fc557362 43@@ -105,6 +105,7 @@ int safe_symlinks = 0;
c66bc26c 44 int copy_unsafe_links = 0;
fc557362 45 int munge_symlinks = 0;
c66bc26c
WD
46 int size_only = 0;
47+int date_only = 0;
bad31232 48 int daemon_bwlimit = 0;
c66bc26c 49 int bwlimit = 0;
a5e0f697 50 int fuzzy_basis = 0;
fc557362 51@@ -739,6 +740,7 @@ void usage(enum logcode F)
79f132a1 52 rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n");
fc557362 53 rprintf(F," -M, --remote-option=OPTION send OPTION to the remote side only\n");
79f132a1
WD
54 rprintf(F," --size-only skip files that match in size\n");
55+ rprintf(F," --date-only skip files that match in mod-time\n");
56 rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n");
d4e89c6a 57 rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
a5e0f697 58 rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
fc557362 59@@ -887,6 +889,7 @@ static struct poptOption long_options[] = {
9a7eef96 60 {"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 },
c66bc26c
WD
61 {"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
62 {"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
63+ {"date-only", 0, POPT_ARG_NONE, &date_only, 0, 0, 0 },
e0e47893 64 {"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
85096e5e
WD
65 {"no-one-file-system",'x',POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
66 {"no-x", 'x', POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
fc557362
WD
67@@ -2493,6 +2496,9 @@ void server_options(char **args, int *argc_p)
68 else if (missing_args == 1 && !am_sender)
69 args[ac++] = "--ignore-missing-args";
78114162 70
c66bc26c
WD
71+ if (date_only)
72+ args[ac++] = "--date-only";
78114162 73+
c66bc26c
WD
74 if (modify_window_set) {
75 if (asprintf(&arg, "--modify-window=%d", modify_window) < 0)
78114162 76 goto oom;
cc3e685d 77diff --git a/rsync.yo b/rsync.yo
fc557362 78index 941f7a5..710b32d 100644
cc3e685d
WD
79--- a/rsync.yo
80+++ b/rsync.yo
fc557362 81@@ -394,6 +394,7 @@ to the detailed description below for a complete description. verb(
cc3e685d 82 --contimeout=SECONDS set daemon connection timeout in seconds
79f132a1
WD
83 -I, --ignore-times don't skip files that match size and time
84 --size-only skip files that match in size
85+ --date-only skip files that match in mod-time
86 --modify-window=NUM compare mod-times with reduced accuracy
ed1e6fe4 87 -T, --temp-dir=DIR create temporary files in directory DIR
a5e0f697 88 -y, --fuzzy find similar file for basis if no dest file
fc557362 89@@ -554,6 +555,12 @@ time to just looking for files that have changed in size. This is useful
c8a8b4a7
WD
90 when starting to use rsync after using another mirroring system which may
91 not preserve timestamps exactly.
78114162 92
c66bc26c
WD
93+dit(bf(--date-only)) Normally rsync will skip any files that are
94+already the same size and have the same modification time-stamp. With the
95+--date-only option, files will be skipped if they have the same
96+timestamp, regardless of size. This may be useful when the remote
97+files have passed through a size-changing filter, e.g. for encryption.
78114162 98+
c1adaf30
WD
99 dit(bf(--modify-window)) When comparing two timestamps, rsync treats the
100 timestamps as being equal if they differ by no more than the modify-window
101 value. This is normally 0 (for an exact match), but you may find it useful