compare-dest when DEST contains path component

Koblinger Egmont egmont at
Sun Jul 6 02:22:24 EST 2003


I just noticed that the value of the '--compare-dest' argument is simply
prepended to the DEST argument, even if that has path compnents. For
example with this command:

rsync -a --compare-dest=$comparedest \
	remote::something/1/ \

if the remote 'something' module has a file called '1/2/3/4/file' (which
is going to be mirrored to '/local/path/to/1/2/3/4/file') it is compared
to the alternate local file '$comparedest/local/path/to/1/2/3/4/file' no
matter if $comparedest is a relative or absolute path.

I really dislike this behavior, since this way I can only compare to local
files which are under '<some_directory>/local/path/to/1', even though I
might want to compare to files that are somewhere else.
Furthermore, this contradits the manpage which says ``If DIR is a relative
path, it is relative to the destination directory.'' -- no, it is
currently relative to the current directory.

I think that it would be more useful if the path would be removed from the
destination argument of rsync before attepting to find an alternate local
file, that is, the example above would use the local file
'$comparedest/2/3/4/file'. For relative paths, I don't know whether
'$comparedest/2/3/4/file' or '/local/path/to/1/$comparedest/2/3/4/file'
would be the better, but I think either of them is better than the current
behaviour. This way I'm not forced to put the reference local file under
'<some_directory>/local/path/to/1', but I can still duplicate the path
component '/local/path/to/1' in the value of $comparedest if I want to get
the current behaviour.

(I wanted to use apt-get with rsync. The apt-get engine asks its module
(http, ftp, rsync...) to put the new file under
'/var/cache/apt/archives/partial' and it will move it to
'/var/cache/apt/archives' later. However I want rsync to use already
existing files under '/var/cache/apt/archives' as reference files. The
apt-get rsync module calls rsync with full pathname arguments, and its
source is a little bit complicated to me so it is not trivial to work
around this problem by cd'ing to '/var/cache/apt/archives/partial' and
calling rsync with a slash-free last argument.)

Another problem is that I applied Rusty's fuzzy filename patch (to 2.5.4,
I was unable to port it to 2.5.6), however this patch is not really
compatible with --compare-dest. rsync still only looks for exact filenames
under this alternate local directory. I've read that merging this patch is
planned for rsync 2.6. If it happens, please consider making these two
options like each other: I guess that giving both --fuzzy and
--compare-dest should look for fuzzy filenames under both the real
destination directory and the one given with --compare-dest.

(I've solved these problems for myself, so don't bother with sending
quick&dirty patches :-))  However I'd really like to see a proper solution
for both problems in the mainstream version. My quick&dirty patch
introduces a new option (not to break existing ones) which does exactly
what I want and nothing more :-))) It can be downloaded from here:



More information about the rsync mailing list