On Tue, 2008-08-12 at 19:11 +0800, Thomas Gutzler wrote:
> I've recently noticed that running rsync -m --compare-dest creates
> empty directories, even though it should be prevented by the -m flag.
> Try rsync -avm --compare-dest=/path/to/dir/ /path/to/dir/ foo
> and you get a nice copy of the directory structure in foo - with no filesin it.
> I was wondering if there's a reason for that and if there's a way to
> get around it


-m operates on the file list, so it sees the directories as nonempty; it
doesn't know that the files inside are all being skipped by
--compare-dest.

Furthermore, directories are never skipped by --compare-dest. I'm
guessing this is because rsync does not know at the time it processes a
directory whether it will be creating any files inside, and later on
when a file is created, it would be inconvenient to go back and look up
the attributes to set on its ancestor directories. This behavior is not
ideal but would be a bit messy to fix.

Even if you give rsync a list of just the non-directory files with
--files-from and --no-implied-dirs, it will still create the ancestor
directories of a file before seeing that the file is skipped by
--no-implied-dirs. That appears to be fixable with some extra code but
without too much mess: instead of creating the ancestor directories at
line 1339 of generator.c, the generator would set a flag that they are
needed and create them if necessary around lines 1578, 1657, and 1748.

One workaround would be to follow up with a copy of the destination to
itself using -m and --delete.

Matt

--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkiiHrcACgkQC+xSYN/Rlfu1PgCfTGR8BD8Ofds/d4v/XnxgJY0z
3zQAnA4Ibz51SloiEVgOuinXOnrLBkNk
=yStg
-----END PGP SIGNATURE-----