+--- old/compat.c
++++ new/compat.c
+@@ -41,6 +41,7 @@ extern int checksum_seed;
+ extern int basis_dir_cnt;
+ extern int prune_empty_dirs;
+ extern int protocol_version;
++extern int detect_renamed;
+ extern int protect_args;
+ extern int preserve_uid;
+ extern int preserve_gid;
+@@ -218,7 +219,7 @@ void setup_protocol(int f_out,int f_in)
+ } else if (protocol_version >= 30) {
+ if (recurse && allow_inc_recurse
+ && !delete_before && !delete_after && !delay_updates
+- && !use_qsort && !prune_empty_dirs)
++ && !use_qsort && !prune_empty_dirs && !detect_renamed)
+ inc_recurse = 1;
+ need_messages_from_generator = 1;
+ }
-@@ -77,6 +78,8 @@ static dev_t tmp_rdev;
- static struct idev tmp_idev;
- static char tmp_sum[MD4_SUM_LENGTH];
+@@ -113,6 +114,8 @@ static int64 tmp_dev, tmp_ino;
+ #endif
+ static char tmp_sum[MAX_DIGEST_LEN];
- static char empty_sum[MD4_SUM_LENGTH];
- static int flist_count_offset;
-
-@@ -259,6 +262,44 @@ static mode_t from_wire_mode(int mode)
- return mode;
+ static char empty_sum[MAX_DIGEST_LEN];
+ static int flist_count_offset; /* for --delete --progress */
+ static int dir_count = 0;
+@@ -252,6 +255,45 @@ static int is_excluded(char *fname, int
+ return 0;
}
+static int fattr_compare(struct file_struct **file1, struct file_struct **file2)
+{
+ struct file_struct *f1 = *file1;
+ struct file_struct *f2 = *file2;
}
+static int fattr_compare(struct file_struct **file1, struct file_struct **file2)
+{
+ struct file_struct *f1 = *file1;
+ struct file_struct *f2 = *file2;
-@@ -1411,6 +1452,25 @@ struct file_list *recv_file_list(int f)
-
- clean_flist(flist, relative_paths, 1);
+@@ -2021,6 +2063,25 @@ struct file_list *send_file_list(int f,
+ if (verbose > 2)
+ rprintf(FINFO, "send_file_list done\n");
+ the_fattr_list.files = new_array(struct file_struct *, j);
+ if (!the_fattr_list.files)
+ out_of_memory("recv_file_list");
+ memcpy(the_fattr_list.files, flist->files,
+ j * sizeof (struct file_struct *));
+ qsort(the_fattr_list.files, j,
+ the_fattr_list.files = new_array(struct file_struct *, j);
+ if (!the_fattr_list.files)
+ out_of_memory("recv_file_list");
+ memcpy(the_fattr_list.files, flist->files,
+ j * sizeof (struct file_struct *));
+ qsort(the_fattr_list.files, j,
static int deletion_count = 0; /* used to implement --max-delete */
+static int unexplored_dirs = 1;
static int deldelay_size = 0, deldelay_cnt = 0;
static char *deldelay_buf = NULL;
static int deldelay_fd = -1;
static int deletion_count = 0; /* used to implement --max-delete */
+static int unexplored_dirs = 1;
static int deldelay_size = 0, deldelay_cnt = 0;
static char *deldelay_buf = NULL;
static int deldelay_fd = -1;
+ * time (plus the basename, if possible) or (2) the size & checksum. If
+ * we find an exact match down to the dirname, return -1 because we found
+ * an up-to-date file in the transfer, not a renamed file. */
+ * time (plus the basename, if possible) or (2) the size & checksum. If
+ * we find an exact match down to the dirname, return -1 because we found
+ * an up-to-date file in the transfer, not a renamed file. */
+{
+ int low = the_fattr_list.low, high = the_fattr_list.high;
+ int mid, ok_match = -1, good_match = -1;
+{
+ int low = the_fattr_list.low, high = the_fattr_list.high;
+ int mid, ok_match = -1, good_match = -1;
+ if (fmid->modtime == f->modtime
+ && f_name_cmp(fmid, f) == 0)
+ return -1; /* assume we can't help */
+ if (fmid->modtime == f->modtime
+ && f_name_cmp(fmid, f) == 0)
+ return -1; /* assume we can't help */
-+ /* XXX update this to new checksum var idiom! */
-+ F_SUM(f) = pool_alloc(pool, MD4_SUM_LENGTH,
-+ "fattr_find");
-+ file_checksum(fname, F_SUM(f), f->length);
++ file_checksum(fname, F_SUM(f), F_LENGTH(f));
++ f->flags |= FLAG_FILE_SENT;
* its contents, otherwise just checks for content. Returns DR_SUCCESS or
* DR_NOT_EMPTY. Note that fname must point to a MAXPATHLEN buffer! (The
* buffer is used for recursion, but returned unchanged.)
* its contents, otherwise just checks for content. Returns DR_SUCCESS or
* DR_NOT_EMPTY. Note that fname must point to a MAXPATHLEN buffer! (The
* buffer is used for recursion, but returned unchanged.)
-@@ -252,6 +370,8 @@ static enum delret delete_dir_contents(c
+@@ -227,7 +344,9 @@ static enum delret delete_dir_contents(c
+ save_filters = push_local_filters(fname, dlen);
+
+ non_perishable_cnt = 0;
++ file_extra_cnt += SUM_EXTRA_CNT;
+ dirlist = get_dirlist(fname, dlen, 0);
++ file_extra_cnt -= SUM_EXTRA_CNT;
+ ret = non_perishable_cnt ? DR_NOT_EMPTY : DR_SUCCESS;
+
+ if (!dirlist->used)
+@@ -264,6 +383,8 @@ static enum delret delete_dir_contents(c
* all the --delete-WHEN options. Note that the fbuf pointer must point to a
* MAXPATHLEN buffer with the name of the directory in it (the functions we
* call will append names onto the end, but the old dir value will be restored
- * on exit). */
* all the --delete-WHEN options. Note that the fbuf pointer must point to a
* MAXPATHLEN buffer with the name of the directory in it (the functions we
* call will append names onto the end, but the old dir value will be restored
- * on exit). */
- static void delete_in_dir(struct file_list *flist, char *fbuf,
-- struct file_struct *file, STRUCT_STAT *stp)
-+ struct file_struct *file, STRUCT_STAT *stp, int flags)
++static void delete_in_dir(char *fbuf, struct file_struct *file, dev_t *fs_dev,
++ int flags)
-- delete_in_dir(flist, fbuf, file, &st);
-+ delete_in_dir(flist, fbuf, file, &st, 0);
+- delete_in_dir(fbuf, file, &st.st_dev);
++ delete_in_dir(fbuf, file, &st.st_dev, 0);
-- delete_in_dir(NULL, NULL, NULL, NULL);
-+ delete_in_dir(NULL, NULL, NULL, NULL, 0);
+- delete_in_dir(NULL, NULL, &dev_zero);
++ delete_in_dir(NULL, NULL, &dev_zero, 0);
- /* Acts on the_file_list->file's ndx'th item, whose name is fname. If a dir,
-@@ -1228,8 +1372,12 @@ static void recv_generator(char *fname,
- if (real_ret != 0 && one_file_system)
- real_st.st_dev = filesystem_dev;
- if (delete_during && f_out != -1 && !phase && dry_run < 2
+@@ -1345,8 +1491,12 @@ static void recv_generator(char *fname,
+ }
+ }
+ else if (delete_during && f_out != -1 && !phase && dry_run < 2
-@@ -1500,8 +1648,14 @@ static void recv_generator(char *fname,
- itemizing, code, HL_SKIP))
- return;
+@@ -1624,8 +1774,14 @@ static void recv_generator(char *fname,
+ goto cleanup;
+ }
- return;
-@@ -1691,6 +1845,12 @@ void generate_files(int f_out, struct fi
- (long)getpid(), flist->count);
- }
+ goto cleanup;
+@@ -1961,6 +2117,12 @@ void generate_files(int f_out, const cha
+ if (verbose > 2)
+ rprintf(FINFO, "generator starting pid=%ld\n", (long)getpid());
-@@ -1758,7 +1918,23 @@ void generate_files(int f_out, struct fi
- }
- recv_generator(NULL, NULL, 0, 0, 0, code, -1);
+@@ -2009,7 +2171,7 @@ void generate_files(int f_out, const cha
+ dirdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
+ } else
+ dirdev = MAKEDEV(0, 0);
+- delete_in_dir(f_name(fp, fbuf), fp, &dirdev);
++ delete_in_dir(f_name(fp, fbuf), fp, &dirdev, 0);
+ }
+ }
+ }
+@@ -2054,7 +2216,21 @@ void generate_files(int f_out, const cha
+ } while ((cur_flist = cur_flist->next) != NULL);
+
-- delete_in_dir(NULL, NULL, NULL, NULL);
-+ delete_in_dir(NULL, NULL, NULL, NULL, 0);
-+
+- delete_in_dir(NULL, NULL, &dev_zero);
++ delete_in_dir(NULL, NULL, &dev_zero, 0);
-+ recv_generator(fbuf, file, i, itemizing,
-+ maybe_ATTRS_REPORT, code, f_out);
++ recv_generator(fbuf, file, i, itemizing, code, f_out);
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");
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");
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");
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");
{"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 },
+ {"detect-renamed", 0, POPT_ARG_NONE, &detect_renamed, 0, 0, 0 },
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
{"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 },
+ {"detect-renamed", 0, POPT_ARG_NONE, &detect_renamed, 0, 0, 0 },
{"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 },
-@@ -1361,7 +1364,7 @@ int parse_arguments(int *argc, const cha
+ {"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
+@@ -1533,7 +1536,7 @@ int parse_arguments(int *argc_p, const c
snprintf(err_buf, sizeof err_buf,
"--%s cannot be used with --%s\n",
append_mode ? "append" : "inplace",
snprintf(err_buf, sizeof err_buf,
"--%s cannot be used with --%s\n",
append_mode ? "append" : "inplace",
--modify-window=NUM compare mod-times with reduced accuracy
-T, --temp-dir=DIR create temporary files in directory DIR
-y, --fuzzy find similar file for basis if no dest file
--modify-window=NUM compare mod-times with reduced accuracy
-T, --temp-dir=DIR create temporary files in directory DIR
-y, --fuzzy find similar file for basis if no dest file
--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
--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