DO NOT REPLY [Bug 4764] Wrong include/exclude descriptions

samba-bugs at samba-bugs at
Fri Jul 6 01:16:00 GMT 2007

------- Comment #10 from hashproduct+rsync at  2007-07-05 20:16 CST -------
(In reply to comment #7)
> OK:
> + /some/path/this-file-will-not-be-found
> + /file-is-included
> - *
> This fails because the parent directory "some" is excluded by the '*' rule, so
> rsync never visits any of the files in the "some" or "some/path" directories.''
> If I interpret correctly, what this states, it means '/**/6/' is useless
> combined with '- *', since no directory will ever be matched, since you are not
> expanding first to find a match for '/**/6/'? It is not clear.

Did you read the previous paragraph?  It says, "If a pattern excludes a
particular parent directory, it can render a deeper include pattern ineffectual
because rsync did not descend through that excluded section of the hierarchy." 
To me, this makes it clear that an exclude pattern cuts rsync off altogether
from scanning a subtree of the source so that files inside that subtree are
never even considered for transmission, whether or not they would be included
according to your rules.  There is nothing in the man page to justify the
interpretation that rsync "expand[s] first to find a match for '/**/6/'".

> The same is with
> + 6/
> - *
> are you traversing all directories, or just reading the contents of the one we
> are in?  The manpage states that '+ 6/ finds any directory named '6'.

No, nowhere does the manpage state that include patterns "find" anything.  '+
6/' matches and includes any directory named '6' *if and when* such a directory
is encountered during the traversal.

> Thus I
> assume you traversing all available directories first, looking for one matching
> '6'? If this is not true, meaning you are testing within the directory we are
> in if there is no match (one named '6') discarding them, never traversing down
> the tree?
> This is not clearly stated.

I'm ignoring this because it is based on a statement that isn't in the manpage.

> I am missing a clear description what is matched by
> all those rules spawning more than just one directory:
> + **/
> + /**/
> + 6/ (implicitly something like (**/6/)
> If you are assuming
> /fedora/core/6
> you are reading only
> /fedora
> comparing against '/**/6/'. Since this does not match the '- *' is applied.
> This matches. The directory is removed?!


> I'd assume with
> + /**/6/
> - *
> you'd try to find a match expanding until there is none. Meaning:
> /fedora has subdirectory /core has subdirectory /6, this matches /**/6, since
> /**/ matches any path, thus /fedora/core/6 is matched.

There is nothing in the manpage to justify this assumption.  If you are misled
by your own faulty assumption, that's your fault, not rsync's.

> If this isn't done,
> state it clearly. '/**/6' this way will never match anything if followed by a
> rule like '- *'.

The example I quoted from the manpage is intended to explain just that:

``For instance, this won't work:

+ /some/path/this-file-will-not-be-found
+ /file-is-included
- *

This fails because the parent directory "some" is excluded by the '*' rule, so
rsync never visits any of the files in the "some" or "some/path" directories.''

Granted, that example isn't as explicit as it possibly could be that the first
rule has no effect, but it ought to be enough to catch the attention of people
using a similar filter file (like you) and get them to read the rest of the
description so they understand why it won't work.

> If you are in need of including only certain deeply nested subdirectories the
> includes are not not of use in most cases and the only way transfering deeply
> nested directories would be to analyze a whole directory traversal by rsync
> feeding the output into grep, sed, or any tool capable of handling strings
> efficiently, creating an include file yourself.

No, the man page goes on to explain another alternative:

``One solution is to ask for all directories in the hierarchy to be included by
using a single rule: "+ */" (put it somewhere before the "- *" rule), and
perhaps use the --prune-empty-dirs option.''

If you wanted rsync to provide an easier way to include only certain
subdirectories, that would be a legitimate feature request.

Configure bugmail:
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

More information about the rsync mailing list