- if (hf_hl->hlindex == FINISHED_LINK) {
- STRUCT_STAT st2, st3;
- char toname[MAXPATHLEN];
- int ldu = hf_hl->dest_used;
- if (ldu) {
- pathjoin(toname, MAXPATHLEN, basis_dir[ldu-1],
- f_name(head_file, NULL));
- } else
- f_name(head_file, toname);
- if (link_stat(toname, &st2, 0) < 0) {
- rsyserr(FERROR, errno, "stat %s failed",
- full_fname(toname));
- return -1;
- }
- if (statret < 0 && basis_dir[0] != NULL) {
- char cmpbuf[MAXPATHLEN];
- int j = 0;
- do {
- pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
- if (link_stat(cmpbuf, &st3, 0) < 0)
- continue;
- if (link_dest) {
- if (st2.st_dev != st3.st_dev
- || st2.st_ino != st3.st_ino)
- continue;
- statret = 1;
- stp = &st3;
- if (verbose < 2 || !stdout_format_has_i) {
- itemizing = 0;
- code = FNONE;
- }
- break;
- }
- if (!unchanged_file(cmpbuf, file, &st3))
- continue;
- statret = 1;
- stp = &st3;
- if (unchanged_attrs(file, &st3))
- break;
- } while (basis_dir[++j] != NULL);
+ return 0;
+ }
+
+ /* There is a finished file to link with! */
+ if (!(prev_file->flags & FLAG_HLINK_FIRST)) {
+ /* The previous previous will be marked with FIRST. */
+ prev_ndx = F_HL_PREV(prev_file);
+ prev_file = FPTR(prev_ndx);
+ /* Update our previous pointer to point to the first. */
+ F_HL_PREV(file) = prev_ndx;
+ }
+ alt_dest = F_HL_PREV(prev_file); /* alternate value when DONE && FIRST */
+ if (alt_dest >= 0 && dry_run) {
+ pathjoin(prev_name, MAXPATHLEN, basis_dir[alt_dest],
+ f_name(prev_file, NULL));
+ f_name(prev_file, altbuf);
+ realname = altbuf;
+ } else {
+ f_name(prev_file, prev_name);
+ realname = prev_name;
+ }
+
+ if (link_stat(prev_name, &prev_st, 0) < 0) {
+ rsyserr(FERROR, errno, "stat %s failed",
+ full_fname(prev_name));
+ return -1;
+ }
+
+ if (statret < 0 && basis_dir[0] != NULL) {
+ /* If we match an alt-dest item, we don't output this as a change. */
+ char cmpbuf[MAXPATHLEN];
+ STRUCT_STAT alt_st;
+ int j = 0;
+ do {
+ pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
+ if (link_stat(cmpbuf, &alt_st, 0) < 0)
+ continue;
+ if (link_dest) {
+ if (prev_st.st_dev != alt_st.st_dev
+ || prev_st.st_ino != alt_st.st_ino)
+ continue;
+ statret = 1;
+ *stp = alt_st;
+ if (verbose < 2 || !stdout_format_has_i) {
+ itemizing = 0;
+ code = FNONE;
+ if (verbose > 1 && maybe_ATTRS_REPORT)
+ rprintf(FCLIENT, "%s is uptodate\n", fname);
+ }
+ break;