Fixed 2 failing hunks.
[rsync/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 --- old/generator.c
11 +++ new/generator.c
12 @@ -54,6 +54,7 @@ extern int ignore_errors;
13  extern int remove_source_files;
14  extern int delay_updates;
15  extern int update_only;
16 +extern int downdate_only;
17  extern int ignore_existing;
18  extern int ignore_non_existing;
19  extern int inplace;
20 @@ -1528,6 +1529,13 @@ static void recv_generator(char *fname, 
21                 goto cleanup;
22         }
23  
24 +       if (downdate_only && statret == 0
25 +           && cmp_time(sx.st.st_mtime, file->modtime) < 0) {
26 +               if (verbose > 1)
27 +                       rprintf(FINFO, "%s is older\n", fname);
28 +               return;
29 +       }
30 +
31         fnamecmp = fname;
32         fnamecmp_type = FNAMECMP_FNAME;
33  
34 @@ -1825,6 +1833,7 @@ void check_for_finished_files(int itemiz
35                 ignore_existing = -ignore_existing;
36                 ignore_non_existing = -ignore_non_existing;
37                 update_only = -update_only;
38 +               downdate_only = -downdate_only;
39                 always_checksum = -always_checksum;
40                 size_only = -size_only;
41                 append_mode = -append_mode;
42 @@ -1850,6 +1859,7 @@ void check_for_finished_files(int itemiz
43                 ignore_existing = -ignore_existing;
44                 ignore_non_existing = -ignore_non_existing;
45                 update_only = -update_only;
46 +               downdate_only = -downdate_only;
47                 always_checksum = -always_checksum;
48                 size_only = -size_only;
49                 append_mode = -append_mode;
50 --- old/options.c
51 +++ new/options.c
52 @@ -57,6 +57,7 @@ int preserve_uid = 0;
53  int preserve_gid = 0;
54  int preserve_times = 0;
55  int update_only = 0;
56 +int downdate_only = 0;
57  int cvs_exclude = 0;
58  int dry_run = 0;
59  int do_xfers = 1;
60 @@ -318,6 +319,7 @@ void usage(enum logcode F)
61    rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");
62    rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
63    rprintf(F," -u, --update                skip files that are newer on the receiver\n");
64 +  rprintf(F," -w, --downdate              skip files that are older on the receiver\n");
65    rprintf(F,"     --inplace               update destination files in-place (SEE MAN PAGE)\n");
66    rprintf(F,"     --append                append data onto shorter files\n");
67    rprintf(F,"     --append-verify         like --append, but with old data in file checksum\n");
68 @@ -522,6 +524,7 @@ static struct poptOption long_options[] 
69    {"size-only",        0,  POPT_ARG_NONE,   &size_only, 0, 0, 0 },
70    {"one-file-system", 'x', POPT_ARG_NONE,   0, 'x', 0, 0 },
71    {"update",          'u', POPT_ARG_NONE,   &update_only, 0, 0, 0 },
72 +  {"downdate",        'w', POPT_ARG_NONE,   &downdate_only, 0, 0, 0 },
73    {"existing",         0,  POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
74    {"ignore-non-existing",0,POPT_ARG_NONE,   &ignore_non_existing, 0, 0, 0 },
75    {"ignore-existing",  0,  POPT_ARG_NONE,   &ignore_existing, 0, 0, 0 },