docs/rationale/source-filter-last-match-wins.md
Bear can include or exclude source files from the compilation database by
directory rules (sources.directories). The original feature request
(GitHub issue #261) raised the question of precedence: when a file matches
several rules with conflicting actions, which one decides?
Two policies were on the table:
src, exclude src/test, then re-include
src/test/integration).Use order-based evaluation where the last matching rule wins, with the default action being "include" when no rule matches.
Users get full control over precedence by ordering rules, including
exceptions-to-exceptions, which a fixed policy cannot express. A common
pattern is a . catch-all first, then more specific rules after it. The
cost is that precedence is now positional: reordering rules changes
behaviour, so the rule list is order-sensitive and the user owns getting
the order right. Matching itself is literal prefix matching
(Path::starts_with), so rule paths must use the same path format the
entries are written in (output-path-format).
output-source-directory-filter