-- maybe_hard_link(file, ndx, fname, statret, st,
-+ maybe_hard_link(file, ndx, fname, statret, sxp,
- toname, &st2, itemizing, code);
- if (remove_source_files == 1 && do_xfers) {
- char numbuf[4];
-@@ -249,7 +258,7 @@ int hard_link_check(struct file_struct *
-
- #ifdef SUPPORT_HARD_LINKS
- int hard_link_one(struct file_struct *file, int ndx, char *fname,
-- int statret, STRUCT_STAT *st, char *toname, int terse,
-+ int statret, statx *sxp, char *toname, int terse,
- int itemizing, enum logcode code)
- {
- if (do_link(toname, fname)) {
-@@ -265,7 +274,11 @@ int hard_link_one(struct file_struct *fi
- }
-
- if (itemizing) {
-- itemize(file, ndx, statret, st,
+- if (!unchanged_file(cmpbuf, file, &alt_st))
++ if (!unchanged_file(cmpbuf, file, &alt_sx.st))
+ continue;
+ statret = 1;
+- *stp = alt_st;
+- if (unchanged_attrs(file, &alt_st))
++#ifdef SUPPORT_ACLS
++ if (preserve_acls)
++ get_acl(cmpbuf, &alt_sx);
++#endif
++ if (unchanged_attrs(file, &alt_sx))
+ break;
+ } while (basis_dir[++j] != NULL);
++ if (statret == 1) {
++ sxp->st = alt_sx.st;
++#ifdef SUPPORT_ACLS
++ if (preserve_acls) {
++ if (!ACL_READY(*sxp))
++ get_acl(cmpbuf, sxp);
++ else {
++ sxp->acc_acl = alt_sx.acc_acl;
++ sxp->def_acl = alt_sx.def_acl;
++ }
++ }
++#endif
++ }