The patches for 3.3.0.
[rsync-patches.git] / backup-deleted.diff
index da24ba56089f0ac42bc160a29e52317b711ca967..0cbf2bb0029984a0c6764aec488f915655c05be6 100644 (file)
@@ -7,11 +7,11 @@ To use this patch, run these commands for a successful build:
     ./configure                                 (optional if already run)
     make
 
-based-on: 2ac35b45071c7bfd8be6be41bfd45326f1f57bce
+based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -1780,7 +1780,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1846,7 +1846,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                goto notify_others;
  
        if (read_batch || whole_file) {
@@ -20,16 +20,16 @@ diff --git a/generator.c b/generator.c
                        if (!(backupptr = get_backup_name(fname)))
                                goto cleanup;
                        if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
-@@ -1816,7 +1816,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1882,7 +1882,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                goto notify_others;
        }
  
 -      if (inplace && make_backups > 0 && fnamecmp_type == FNAMECMP_FNAME) {
 +      if (inplace && make_backups > 1 && fnamecmp_type == FNAMECMP_FNAME) {
                if (!(backupptr = get_backup_name(fname))) {
-                       close(fd);
                        goto cleanup;
-@@ -1940,7 +1940,7 @@ int atomic_create(struct file_struct *file, char *fname, const char *slnk, const
+               }
+@@ -2002,7 +2002,7 @@ int atomic_create(struct file_struct *file, char *fname, const char *slnk, const
                skip_atomic = 0;
  
        if (del_for_flag) {
@@ -41,15 +41,7 @@ diff --git a/generator.c b/generator.c
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -679,6 +679,7 @@ void usage(enum logcode F)
-   rprintf(F," -R, --relative              use relative path names\n");
-   rprintf(F,"     --no-implied-dirs       don't send implied dirs with --relative\n");
-   rprintf(F," -b, --backup                make backups (see --suffix & --backup-dir)\n");
-+  rprintf(F,"     --backup-deleted        make backups only of deleted files\n");
-   rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");
-   rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
-   rprintf(F," -u, --update                skip files that are newer on the receiver\n");
-@@ -993,7 +994,8 @@ static struct poptOption long_options[] = {
+@@ -776,7 +776,8 @@ static struct poptOption long_options[] = {
    {"no-i",             0,  POPT_ARG_VAL,    &itemize_changes, 0, 0, 0 },
    {"bwlimit",          0,  POPT_ARG_STRING, &bwlimit_arg, OPT_BWLIMIT, 0, 0 },
    {"no-bwlimit",       0,  POPT_ARG_VAL,    &bwlimit, 0, 0, 0 },
@@ -59,8 +51,8 @@ diff --git a/options.c b/options.c
    {"no-backup",        0,  POPT_ARG_VAL,    &make_backups, 0, 0, 0 },
    {"backup-dir",       0,  POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
    {"suffix",           0,  POPT_ARG_STRING, &backup_suffix, 0, 0, 0 },
-@@ -2599,6 +2601,10 @@ void server_options(char **args, int *argc_p)
-       }
+@@ -2805,6 +2806,10 @@ void server_options(char **args, int *argc_p)
+               args[ac++] = safe_arg("--compress-choice", compress_choice);
  
        if (am_sender) {
 +              /* A remote sender just needs the above -b option.
@@ -73,7 +65,7 @@ diff --git a/options.c b/options.c
 diff --git a/receiver.c b/receiver.c
 --- a/receiver.c
 +++ b/receiver.c
-@@ -422,7 +422,7 @@ static void handle_delayed_updates(char *local_name)
+@@ -427,7 +427,7 @@ static void handle_delayed_updates(char *local_name)
                struct file_struct *file = cur_flist->files[ndx];
                fname = local_name ? local_name : f_name(file, NULL);
                if ((partialptr = partial_dir_fname(fname)) != NULL) {
@@ -82,7 +74,7 @@ diff --git a/receiver.c b/receiver.c
                                continue;
                        if (DEBUG_GTE(RECV, 1)) {
                                rprintf(FINFO, "renaming %s to %s\n",
-@@ -736,7 +736,7 @@ int recv_files(int f_in, int f_out, char *local_name)
+@@ -748,7 +748,7 @@ int recv_files(int f_in, int f_out, char *local_name)
                } else {
                        /* Reminder: --inplace && --partial-dir are never
                         * enabled at the same time. */
@@ -91,10 +83,35 @@ diff --git a/receiver.c b/receiver.c
                                if (!(fnamecmp = get_backup_name(fname)))
                                        fnamecmp = fname;
                                else
+diff --git a/rsync.1.md b/rsync.1.md
+--- a/rsync.1.md
++++ b/rsync.1.md
+@@ -428,6 +428,7 @@ has its own detailed description later in this manpage.
+ --relative, -R           use relative path names
+ --no-implied-dirs        don't send implied dirs with --relative
+ --backup, -b             make backups (see --suffix & --backup-dir)
++--backup-deleted         make backups only of deleted files
+ --backup-dir=DIR         make backups into hierarchy based in DIR
+ --suffix=SUFFIX          backup suffix (default ~ w/o --backup-dir)
+ --update, -u             skip files that are newer on the receiver
+@@ -1006,6 +1007,13 @@ expand it.
+     rules specify a trailing inclusion/exclusion of `*`, the auto-added rule
+     would never be reached).
++0.  `--backup-deleted`
++
++    With this option, deleted destination files are renamed, while modified
++    destination files are not. Otherwise, this option behaves the same as
++    [`--backup`](#opt), described above.  Note that if [`--backup`](#opt) is
++    also specified, whichever option is specified last takes precedence.
++
+ 0.  `--backup-dir=DIR`
+     This implies the [`--backup`](#opt) option, and tells rsync to store all
 diff --git a/rsync.c b/rsync.c
 --- a/rsync.c
 +++ b/rsync.c
-@@ -656,7 +656,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -733,7 +733,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
                goto do_set_file_attrs;
        }
  
@@ -102,27 +119,4 @@ diff --git a/rsync.c b/rsync.c
 +      if (make_backups > 1 && overwriting_basis) {
                int ok = make_backup(fname, False);
                if (!ok)
-                       return 1;
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -346,6 +346,7 @@ to the detailed description below for a complete description.  verb(
-  -R, --relative              use relative path names
-      --no-implied-dirs       don't send implied dirs with --relative
-  -b, --backup                make backups (see --suffix & --backup-dir)
-+     --backup-deleted        make backups only of deleted files
-      --backup-dir=DIR        make backups into hierarchy based in DIR
-      --suffix=SUFFIX         backup suffix (default ~ w/o --backup-dir)
-  -u, --update                skip files that are newer on the receiver
-@@ -778,6 +779,11 @@ in the list so that it has a high enough priority to be effective (e.g., if
- your rules specify a trailing inclusion/exclusion of '*', the auto-added
- rule would never be reached).
-+dit(bf(--backup-deleted)) With this option, deleted destination files are
-+renamed, while modified destination files are not. Otherwise, this option
-+behaves the same as bf(--backup), described above.  Note that if bf(--backup)
-+is also specified, whichever option is specified last takes precedence.
-+
- dit(bf(--backup-dir=DIR)) In combination with the bf(--backup) option, this
- tells rsync to store all backups in the specified directory on the receiving
- side.  This can be used for incremental backups.  You can additionally
+                       exit_cleanup(RERR_FILEIO);