Patterns for exclusion/inclusion are confusing

This is confusing. According to the first paragraph foo/bar/baz.txt will be matched with first include pattern +foo/bar/* and therefore shouldn’t be excluded by -*. Is it a mistake in documentation or am I missing something?

It’s not excluded by -*. If it was matched with a previous inclusion pattern it is included. Full stop. No further processing occurs. That’s why inclusions have to be listed first in order to make sure that they are not “overwritten” by some exclusion (and vice versa, of course: exclusions that should not be trumped by inclusions should come first):

It takes a while to wrap your head around this. :thinking: Check out the topics tagged #filters for more discussions around this.

That said: the documentation may well be improved. Once you figured out what information might have helped you to grasp things faster, feel free to edit it with clarifications (it’s a wiki).

Check out this one, in particular:

1 Like

That’s what I understand too from the first paragraph I cited (which you also cited just below your paragraph I cited). Then just to make it clear, the second paragraph I cited in my previous post is false, is that correct? I’ll cite it again:

This is not true, right?

OK, this comment from the post you linked explains why it IS true:

1 Like

In other words, duplicacy starts by visiting the top-level directories in your repo, and runs through your include/exclude patterns on them. So, first, duplicacy will decide whether to include foo:

  • Does the rule +foo/bar/* match foo/? No. Try the next rule.
  • Does the rule -* match foo/? Yes. Exclude foo.

Because foo is excluded, foo/bar will never be visited, therefore foo/bar/baz.txt will never be considered.

4 Likes