The patches for 3.3.0.
[rsync-patches.git] / detect-renamed-lax.diff
index 118013cbf6cb63e3b78a24011711b1fc655b1dd9..edb683ea90143ab6fc31c168ba519f3e79d33b53 100644 (file)
@@ -20,10 +20,11 @@ switches to --detect-moved blindly accepts the staged file.
 
 -- Matt McCutchen <hashproduct+rsync@gmail.com>
 
+based-on: patch/master/detect-renamed
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -200,7 +200,9 @@ static int fattr_find(struct file_struct *f, char *fname)
+@@ -467,7 +467,9 @@ static int fattr_find(struct file_struct *f, char *fname)
                                continue;
                        }
                }
@@ -34,11 +35,11 @@ diff --git a/generator.c b/generator.c
                diff = u_strcmp(fmid->basename, f->basename);
                if (diff == 0) {
                        good_match = mid;
-@@ -1985,6 +1987,21 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1991,6 +1993,21 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                fnamecmp = partialptr;
                fnamecmp_type = FNAMECMP_PARTIAL_DIR;
                statret = 0;
-+              if (detect_renamed > 1 && unchanged_file(fnamecmp, file, &sx.st)) {
++              if (detect_renamed > 1 && quick_check_ok(FT_REG, fnamecmp, file, &sx.st)) {
 +                      /* Adopt the partial file. */
 +                      finish_transfer(fname, fnamecmp, NULL, NULL, file, 1, 1);
 +                      handle_partial_dir(partialptr, PDIR_DELETE);
@@ -59,16 +60,7 @@ diff --git a/generator.c b/generator.c
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -393,6 +393,8 @@ void usage(enum logcode F)
-   rprintf(F," -T, --temp-dir=DIR          create temporary files in directory DIR\n");
-   rprintf(F," -y, --fuzzy                 find similar file for basis if no dest file\n");
-   rprintf(F,"     --detect-renamed        try to find renamed files to speed up the transfer\n");
-+  rprintf(F,"     --detect-renamed-lax    ... and assume identical to source files (risky!)\n");
-+  rprintf(F,"     --detect-moved          ... only if basenames match (less risky)\n");
-   rprintf(F,"     --compare-dest=DIR      also compare destination files relative to DIR\n");
-   rprintf(F,"     --copy-dest=DIR         ... and include copies of unchanged files\n");
-   rprintf(F,"     --link-dest=DIR         hardlink to files in DIR when unchanged\n");
-@@ -580,7 +582,9 @@ static struct poptOption long_options[] = {
+@@ -744,7 +744,9 @@ static struct poptOption long_options[] = {
    {"compare-dest",     0,  POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
    {"copy-dest",        0,  POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
    {"link-dest",        0,  POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
@@ -76,10 +68,10 @@ diff --git a/options.c b/options.c
 +  {"detect-renamed",   0,  POPT_ARG_VAL,    &detect_renamed, 1, 0, 0 },
 +  {"detect-renamed-lax",0, POPT_ARG_VAL,    &detect_renamed, 2, 0, 0 },
 +  {"detect-moved",     0,  POPT_ARG_VAL,    &detect_renamed, 3, 0, 0 },
-   {"fuzzy",           'y', POPT_ARG_VAL,    &fuzzy_basis, 1, 0, 0 },
+   {"fuzzy",           'y', POPT_ARG_NONE,   0, 'y', 0, 0 },
    {"no-fuzzy",         0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
    {"no-y",             0,  POPT_ARG_VAL,    &fuzzy_basis, 0, 0, 0 },
-@@ -1949,8 +1953,14 @@ void server_options(char **args, int *argc_p)
+@@ -2838,8 +2840,14 @@ void server_options(char **args, int *argc_p)
                        args[ac++] = "--super";
                if (size_only)
                        args[ac++] = "--size-only";
@@ -93,36 +85,39 @@ diff --git a/options.c b/options.c
 +                      else
 +                              args[ac++] = "--detect-moved";
 +              }
+               if (do_stats)
+                       args[ac++] = "--stats";
        } else {
-               if (skip_compress) {
-                       if (asprintf(&arg, "--skip-compress=%s", skip_compress) < 0)
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -386,6 +386,8 @@ to the detailed description below for a complete description.  verb(
-  -T, --temp-dir=DIR          create temporary files in directory DIR
-  -y, --fuzzy                 find similar file for basis if no dest file
-      --detect-renamed        try to find renamed files to speed the xfer
-+     --detect-renamed-lax    ...& assume identical to src files (risky!)
-+     --detect-moved          ... only if basenames match (less risky)
-      --compare-dest=DIR      also compare received files relative to DIR
-      --copy-dest=DIR         ... and include copies of unchanged files
-      --link-dest=DIR         hardlink to files in DIR when unchanged
-@@ -1496,6 +1498,17 @@ the bf(--partial-dir) option, that directory will be used instead.  These
- potential alternate-basis files will be removed as the transfer progresses.
- This option conflicts with bf(--inplace) and bf(--append).
+diff --git a/rsync.1.md b/rsync.1.md
+--- a/rsync.1.md
++++ b/rsync.1.md
+@@ -508,6 +508,8 @@ has its own detailed description later in this manpage.
+ --temp-dir=DIR, -T       create temporary files in directory DIR
+ --fuzzy, -y              find similar file for basis if no dest file
+ --detect-renamed         try to find renamed files to speed the xfer
++--detect-renamed-lax     ...& assume identical to src files (risky!)
++--detect-moved           ... only if basenames match (less risky)
+ --compare-dest=DIR       also compare destination files relative to DIR
+ --copy-dest=DIR          ... and include copies of unchanged files
+ --link-dest=DIR          hardlink to files in DIR when unchanged
+@@ -2652,6 +2654,20 @@ expand it.
+     otential alternate-basis files will be removed as the transfer progresses.
+     This option conflicts with [`--inplace`](#opt) and [`--append`](#opt).
  
-+dit(bf(--detect-renamed-lax)) This version of bf(--detect-renamed)
-+makes rsync hard-link em(dest/D) to em(dest/S) without verifying that
-+em(src/S) and em(dest/S) have the same data.  This poses a significant risk
-+of corrupting the destination by representing a new source file by an
-+unrelated destination file that coincidentally passes the quick check with the
-+source file.  Use this option only if you accept the risk and disk I/O is a
-+bottleneck.
++0.  `--detect-renamed-lax`
 +
-+dit(bf(--detect-moved)) A less risky variant of bf(--detect-renamed-lax) that
-+only uses a destination file that has the same basename as the new source file.
++    This version of [`--detect-renamed`](#opt) makes rsync hard-link `dest/D`
++    to `dest/S` without verifying that `src/S` and `dest/S` have the same data.
++    This poses a significant risk of corrupting the destination by representing
++    a new source file by an unrelated destination file that coincidentally
++    passes the quick check with the source file.  Use this option only if you
++    accept the risk and disk I/O is a bottleneck.
 +
- dit(bf(--compare-dest=DIR)) This option instructs rsync to use em(DIR) on
- the destination machine as an additional hierarchy to compare destination
- files against doing transfers (if the files are missing in the destination
++0.  `--detect-moved`
++
++    A less risky variant of [`--detect-renamed-lax`](#opt) that only uses a
++    destination file that has the same basename as the new source file.
++
+ 0.  `--compare-dest=DIR`
+     This option instructs rsync to use _DIR_ on the destination machine as an