If the combination of --dry-run, --link-dest, and -H finds a matching
[rsync/rsync.git] / generator.c
index ae7c0ea..15cd325 100644 (file)
@@ -607,15 +607,10 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                         char *cmpbuf, STRUCT_STAT *stp, int itemizing,
                         int maybe_ATTRS_REPORT, enum logcode code)
 {
-       int save_ignore_times = ignore_times;
        int best_match = -1;
        int match_level = 0;
        int j = 0;
 
-       /* We can't let ignore_times affect the unchanged_file() test in
-        * an alternate-dest dir or we will never find any matches. */
-       ignore_times = 0;
-
        do {
                pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
                if (link_stat(cmpbuf, stp, 0) < 0 || !S_ISREG(stp->st_mode))
@@ -644,8 +639,6 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                break;
        } while (basis_dir[++j] != NULL);
 
-       ignore_times = save_ignore_times;
-
        if (!match_level)
                return -1;
 
@@ -664,8 +657,11 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                                          itemizing && verbose > 1,
                                          code) < 0)
                                goto try_a_copy;
-                       if (preserve_hard_links && file->link_u.links)
+                       if (preserve_hard_links && file->link_u.links) {
+                               if (dry_run)
+                                       file->link_u.links->link_dest_used = j + 1;
                                hard_link_cluster(file, ndx, itemizing, code);
+                       }
                } else
 #endif
                if (itemizing)
@@ -1154,7 +1150,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                goto return_with_success;
                        return;
                }
-               if (j != -1) {
+               if (j >= 0) {
                        fnamecmp = fnamecmpbuf;
                        fnamecmp_type = j;
                        statret = 0;