This is now on the trunk.
[rsync/rsync-patches.git] / detect-renamed.diff
index 57659de..9e61a02 100644 (file)
@@ -32,6 +32,25 @@ TODO:
   a file that can't use it, while missing out on giving it to a file
   that could use it.
 
+--- old/compat.c
++++ new/compat.c
+@@ -47,6 +47,7 @@ extern int preserve_hard_links;
+ extern int need_messages_from_generator;
+ extern int delete_mode, delete_before, delete_during, delete_after;
+ extern int delete_excluded;
++extern int detect_renamed;
+ extern int make_backups;
+ extern char *backup_dir, *backup_suffix;
+ extern char *partial_dir;
+@@ -163,7 +164,7 @@ void setup_protocol(int f_out,int f_in)
+       } else if (protocol_version >= 30) {
+               if (recurse && allow_inc_recurse && !preserve_hard_links
+                && !delete_before && !delete_after && !delay_updates
+-               && !prune_empty_dirs)
++               && !prune_empty_dirs && !detect_renamed)
+                       inc_recurse = 1;
+               need_messages_from_generator = 1;
+       }
 --- old/flist.c
 +++ new/flist.c
 @@ -57,6 +57,7 @@ extern int non_perishable_cnt;
@@ -44,14 +63,14 @@ TODO:
  extern struct stats stats;
 @@ -87,6 +88,8 @@ static int64 tmp_dev, tmp_ino;
  #endif
- static char tmp_sum[MD4_SUM_LENGTH];
+ static char tmp_sum[MAX_DIGEST_LEN];
  
 +struct file_list the_fattr_list;
 +
- static char empty_sum[MD4_SUM_LENGTH];
+ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
  
-@@ -271,6 +274,45 @@ static mode_t from_wire_mode(int mode)
+@@ -273,6 +276,45 @@ static mode_t from_wire_mode(int mode)
        return mode;
  }
  
@@ -97,7 +116,7 @@ TODO:
  static void send_directory(int f, struct file_list *flist, int ndx,
                           char *fbuf, int len, int flags);
  
-@@ -1744,6 +1786,25 @@ struct file_list *recv_file_list(int f)
+@@ -1767,6 +1809,25 @@ struct file_list *recv_file_list(int f)
  
        clean_flist(flist, relative_paths, 1);
  
@@ -185,14 +204,14 @@ TODO:
 +                      continue;
 +              }
 +              if (always_checksum) {
-+                      /* We use the FLAG_SENT flag to indicate when we
++                      /* We use the FLAG_FILE_SENT flag to indicate when we
 +                       * have computed the checksum for an entry. */
-+                      if (!(f->flags & FLAG_SENT)) {
++                      if (!(f->flags & FLAG_FILE_SENT)) {
 +                              if (fmid->modtime == f->modtime
 +                               && f_name_cmp(fmid, f) == 0)
 +                                      return -1; /* assume we can't help */
 +                              file_checksum(fname, (char*)F_SUM(f), F_LENGTH(f));
-+                              f->flags |= FLAG_SENT;
++                              f->flags |= FLAG_FILE_SENT;
 +                      }
 +                      diff = u_memcmp(F_SUM(fmid), F_SUM(f), checksum_len);
 +                      if (diff) {
@@ -467,7 +486,7 @@ TODO:
                rprintf(FINFO, "generator starting pid=%ld\n", (long)getpid());
  
 +      if (detect_renamed) {
-+              delayed_bits = bitbag_create(flist->count);
++              delayed_bits = bitbag_create(cur_flist->count);
 +              if (!delete_before && !delete_during)
 +                      delete_during = -1;
 +      }
@@ -493,7 +512,7 @@ TODO:
                        }
                }
                for (i = cur_flist->low; i <= cur_flist->high; i++) {
-@@ -1909,7 +2070,21 @@ void generate_files(int f_out, const cha
+@@ -1911,7 +2072,21 @@ void generate_files(int f_out, const cha
        } while ((cur_flist = cur_flist->next) != NULL);
  
        if (delete_during)
@@ -505,7 +524,7 @@ TODO:
 +              detect_renamed = 0;
 +
 +              for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
-+                      struct file_struct *file = flist->files[i];
++                      struct file_struct *file = cur_flist->files[i];
 +                      if (local_name)
 +                              strlcpy(fbuf, local_name, sizeof fbuf);
 +                      else
@@ -526,7 +545,7 @@ TODO:
  int numeric_ids = 0;
  int allow_8bit_chars = 0;
  int force_delete = 0;
-@@ -351,6 +352,7 @@ void usage(enum logcode F)
+@@ -352,6 +353,7 @@ void usage(enum logcode F)
    rprintf(F,"     --modify-window=NUM     compare mod-times with reduced accuracy\n");
    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");
@@ -534,7 +553,7 @@ TODO:
    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");
-@@ -508,6 +510,7 @@ static struct poptOption long_options[] 
+@@ -513,6 +515,7 @@ 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 },
@@ -542,7 +561,7 @@ TODO:
    {"fuzzy",           'y', POPT_ARG_NONE,   &fuzzy_basis, 0, 0, 0 },
    {"compress",        'z', POPT_ARG_NONE,   0, 'z', 0, 0 },
    {"compress-level",   0,  POPT_ARG_INT,    &def_compress_level, 'z', 0, 0 },
-@@ -1397,7 +1400,7 @@ int parse_arguments(int *argc, const cha
+@@ -1402,7 +1405,7 @@ int parse_arguments(int *argc, const cha
                inplace = 1;
        }
  
@@ -551,7 +570,7 @@ TODO:
                partial_dir = tmp_partialdir;
  
        if (inplace) {
-@@ -1406,6 +1409,7 @@ int parse_arguments(int *argc, const cha
+@@ -1411,6 +1414,7 @@ int parse_arguments(int *argc, const cha
                        snprintf(err_buf, sizeof err_buf,
                                 "--%s cannot be used with --%s\n",
                                 append_mode ? "append" : "inplace",
@@ -559,7 +578,7 @@ TODO:
                                 delay_updates ? "delay-updates" : "partial-dir");
                        return 0;
                }
-@@ -1719,6 +1723,8 @@ void server_options(char **args,int *arg
+@@ -1724,6 +1728,8 @@ void server_options(char **args,int *arg
                        args[ac++] = "--super";
                if (size_only)
                        args[ac++] = "--size-only";