Source directory without a trailing slash

Matt McCutchen matt at
Wed Apr 28 18:06:07 MDT 2010

On Wed, 2010-04-28 at 22:24 +1000, David Schoen wrote:
> Also when I use rsync I like to put slashes on the end of all paths as
> it works closer to the way you're thinking, e.g.:
> rsync -av /path/to/source/directory/ /path/to/destination/directory/
> other wise you will probably end up with two copies after your second
> run, one in /path/to/destination/directory and the second in
> /path/to/destination/directory/directory . Which probably isn't what
> you want.

I believe the behavior you describe is a bug.  "rsync src dest" should
always copy to dest/src .  However, if dest does not exist yet /and/ src
happens to be empty, "solo file" mode will trip and the source path will
be ignored.  This is a pointless inconsistency.  I think an empty
directory should not be regarded as a solo file.  In commit a7d461f,
Wayne changed a comment in get_local_name to suggest that but apparently
did not change the code to match.

I also realize that solo file mode should be disabled if --relative is
on, since that option is a clear sign that the user wants the entire
source path to be used.  That avoids a weird case with --relative
--no-implied-dirs --protocol=29 where the file list contains a single
entry whose path has multiple components and rsync ignores all of them
in favor of the destination path.

While we're beating up on get_local_name, I noticed that rsync returns a
bogus error message if the empty string is passed as the destination

matt at mattlaptop2:~/test/rsync-slashes $ rsync-dev -d src ''
rsync: recv_generator: mkdir "/home/matt/test/rsync-slashes/" failed: No such file or directory (2)
*** Skipping any contents from this failed directory ***
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1152) [sender=3.1.0dev]

This could be checked explicitly at the beginning of get_local_name.


More information about the rsync mailing list