This is a bug, right? (--link-dest)

Matt McCutchen matt at mattmccutchen.net
Mon Apr 5 20:30:12 MDT 2010


On Mon, 2010-04-05 at 21:19 -0500, Randall Cotton wrote:
> ----- Original Message ----- 
> From: "Matt McCutchen" <matt at mattmccutchen.net>
> To: "Randall Cotton" <recotton at earthlink.net>
> Cc: <rsync at lists.samba.org>
> Sent: Monday, April 05, 2010 4:47 PM
> Subject: Re: This is a bug, right? (--link-dest)
> 
> 
> : On Mon, 2010-04-05 at 16:38 -0500, Randall Cotton wrote:
> : > ----- Original Message ----- 
> : > From: "Matt McCutchen" <matt at mattmccutchen.net>
> : > To: "Randall Cotton" <recotton at earthlink.net>
> : > Cc: <rsync at lists.samba.org>
> : > Sent: Monday, April 05, 2010 4:16 PM
> : > Subject: Re: This is a bug, right? (--link-dest)
> : >
> : >
> : > : On Mon, 2010-04-05 at 13:57 -0500, Randall Cotton wrote:
> : > : > This works as expected (a hard link is made)
> : > :
> : > : > rsync -a --link-dest=../a.1 a/ b/a
> : > :
> : > : > This does not (a copy is made instead of a hard link)
> : > :
> : > : > rsync -a --link-dest=a.1 a b
> : > :
> 
> [...]
> 
> : The problem is that in the second command, the "a" path component is
> : included in file-list paths.  Hence, rsync will look for the basis file
> : for b/a/tmp at b/a.1/a/tmp instead of b/a.1/tmp .
> 
> Ah, I think I get it now, but let me try to explain it another way and you
> can corroborate (or correct):
> 
> For reference, once again, here are the two sets of rsync commands:
> 
> (hard links of directory hierarchy "a" made successfully with this:)
> rsync -a a/ b/a.1
> rsync -a --link-dest=../a.1 a/ b/a
> 
> (Copies, not hard links, made with this:)
> rsync -a a/ b/a.1
> rsync -a --link-dest=a.1 a b
> 
> The first --link-dest command worked because the source was "a/", which
> stands for "the stuff contained by directory a" (as opposed to just "a",
> which stands for the entire directory hierarchy rooted at and including
> "a"). I specified --link-dest=../a.1 (which maps to b/a/../a.1 = b/a.1,
> since the --link-dest setting is understood to be relative to the
> destination) and that does indeed hold a basis for the source (again, the
> stuff contained by "a", which was deposited by the preceding rsync
> command). So a hard link was made.
> 
> With the second --link-dest command, though, the source was "a" (again,
> the entire directory hierarchy rooted at and including "a"). And
> the --link-dest must always hold a basis for the source. However, I
> specified a --link-dest that maps out to the same place as before (b/a.1)
> which holds exactly the same thing it held before (the stuff *contained*
> by a). That is, in the second --link-dest command, the --link-dest
> directory needed to hold a basis for the actual source ("a" - the entire
> directory hierarchy rooted and including "a"), but instead was still
> holding a basis for "a/" (the stuff *contained* by a). So rsync couldn't
> match up a basis and a copy was made instead of a hard link.
> 
> The --link-dest directory at least *existed*, though, so there was no
> error message. It's just that I didn't point rsync to an
> appropriate --link-dest basis for the source ("a") in that
> second --link-dest command.
> 
> Right?

Yes, this is correct.

My only picky point is that it isn't quite accurate to say that a source
argument of "a/" takes "the stuff contained by directory a", because the
attributes of "a" itself are copied onto the destination directory
"b/a".  I prefer to say that source argument "a/" places the directory
at the root of the file list, while the source argument "a" places it as
a child of the root according to its name.  The basis dir, then, must
always correspond to the root of the file list.

-- 
Matt



More information about the rsync mailing list