The patches for 3.0.4pre2.
[rsync-patches.git] / downdate.diff
1 A patch from Stefan Müller to add the --downdate option, which works
2 in the opposite manner as --update.
3
4 To use this patch, run these commands for a successful build:
5
6     patch -p1 <patches/downdate.diff
7     ./configure                                 (optional if already run)
8     make
9
10 diff --git a/generator.c b/generator.c
11 --- a/generator.c
12 +++ b/generator.c
13 @@ -55,6 +55,7 @@ extern int ignore_errors;
14  extern int remove_source_files;
15  extern int delay_updates;
16  extern int update_only;
17 +extern int downdate_only;
18  extern int ignore_existing;
19  extern int ignore_non_existing;
20  extern int inplace;
21 @@ -1724,6 +1725,13 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
22                 goto cleanup;
23         }
24  
25 +       if (downdate_only && statret == 0
26 +           && cmp_time(sx.st.st_mtime, file->modtime) < 0) {
27 +               if (verbose > 1)
28 +                       rprintf(FINFO, "%s is older\n", fname);
29 +               return;
30 +       }
31 +
32         fnamecmp = fname;
33         fnamecmp_type = FNAMECMP_FNAME;
34  
35 @@ -2096,6 +2104,7 @@ void check_for_finished_files(int itemizing, enum logcode code, int check_redo)
36                         ignore_existing = -ignore_existing;
37                         ignore_non_existing = -ignore_non_existing;
38                         update_only = -update_only;
39 +                       downdate_only = -downdate_only;
40                         always_checksum = -always_checksum;
41                         size_only = -size_only;
42                         append_mode = -append_mode;
43 @@ -2121,6 +2130,7 @@ void check_for_finished_files(int itemizing, enum logcode code, int check_redo)
44                         ignore_existing = -ignore_existing;
45                         ignore_non_existing = -ignore_non_existing;
46                         update_only = -update_only;
47 +                       downdate_only = -downdate_only;
48                         always_checksum = -always_checksum;
49                         size_only = -size_only;
50                         append_mode = -append_mode;
51 diff --git a/options.c b/options.c
52 --- a/options.c
53 +++ b/options.c
54 @@ -60,6 +60,7 @@ int preserve_uid = 0;
55  int preserve_gid = 0;
56  int preserve_times = 0;
57  int update_only = 0;
58 +int downdate_only = 0;
59  int cvs_exclude = 0;
60  int dry_run = 0;
61  int do_xfers = 1;
62 @@ -326,6 +327,7 @@ void usage(enum logcode F)
63    rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");
64    rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
65    rprintf(F," -u, --update                skip files that are newer on the receiver\n");
66 +  rprintf(F," -w, --downdate              skip files that are older on the receiver\n");
67    rprintf(F,"     --inplace               update destination files in-place (SEE MAN PAGE)\n");
68    rprintf(F,"     --append                append data onto shorter files\n");
69    rprintf(F,"     --append-verify         like --append, but with old data in file checksum\n");
70 @@ -534,6 +536,7 @@ static struct poptOption long_options[] = {
71    {"no-one-file-system",'x',POPT_ARG_VAL,   &one_file_system, 0, 0, 0 },
72    {"no-x",            'x', POPT_ARG_VAL,    &one_file_system, 0, 0, 0 },
73    {"update",          'u', POPT_ARG_NONE,   &update_only, 0, 0, 0 },
74 +  {"downdate",        'w', POPT_ARG_NONE,   &downdate_only, 0, 0, 0 },
75    {"existing",         0,  POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
76    {"ignore-non-existing",0,POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
77    {"ignore-existing",  0,  POPT_ARG_NONE,   &ignore_existing, 0, 0, 0 },