Fixed failing hunks.
[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
9a7eef96
WD
17--- old/generator.c
18+++ new/generator.c
f2376a08 19@@ -61,6 +61,7 @@ extern int append_mode;
58a9031f 20 extern int make_backups;
7628f156
WD
21 extern int csum_length;
22 extern int ignore_times;
c66bc26c 23+extern int date_only;
58a9031f
WD
24 extern int size_only;
25 extern OFF_T max_size;
e0e47893 26 extern OFF_T min_size;
f2376a08 27@@ -571,6 +572,9 @@ void itemize(struct file_struct *file, i
4c1f2ca5 28 /* Perform our quick-check heuristic for determining if a file is unchanged. */
e0e47893 29 int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
c66bc26c
WD
30 {
31+ if (date_only)
5b775703 32+ return cmp_time(st->st_mtime, file->modtime) == 0;
1aa236e1
WD
33+
34 if (st->st_size != F_LENGTH(file))
c66bc26c 35 return 0;
4c1f2ca5 36
9a7eef96
WD
37--- old/options.c
38+++ new/options.c
afcb578c 39@@ -99,6 +99,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;
a5e0f697 46 int fuzzy_basis = 0;
1aa236e1 47@@ -340,6 +341,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");
a5e0f697 54 rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
1aa236e1 55@@ -460,6 +462,7 @@ static struct poptOption long_options[]
9a7eef96 56 {"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 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 },
e0e47893 60 {"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
489b0a72 61 {"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
e0e47893 62 {"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
f2376a08 63@@ -1692,6 +1695,9 @@ void server_options(char **args,int *arg
5b775703
WD
64 args[ac++] = "--size-only";
65 }
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;
9a7eef96
WD
73--- old/rsync.yo
74+++ new/rsync.yo
1aa236e1 75@@ -361,6 +361,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
ed1e6fe4 81 -T, --temp-dir=DIR create temporary files in directory DIR
a5e0f697 82 -y, --fuzzy find similar file for basis if no dest file
1aa236e1 83@@ -478,6 +479,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+
c1adaf30
WD
93 dit(bf(--modify-window)) When comparing two timestamps, rsync treats the
94 timestamps as being equal if they differ by no more than the modify-window
95 value. This is normally 0 (for an exact match), but you may find it useful