pub fn normalize_pattern_for_base(pattern: &str, base: Option<&Path>) -> StringExpand description
Normalize a config path pattern for matching against paths discovered under
base: expand a leading ~, then rewrite an absolute pattern as one
relative to base when base contains it.
The rewrite is what makes an absolute pattern usable as a walker override:
the ignore crate reads a leading / as “anchored to the walk base”, so
/home/dev/docs/** would otherwise be understood as
<base>/home/dev/docs/** and match nothing. A pattern pointing outside
base is left absolute - nothing under this walk can match it, which is the
correct outcome.
A pattern can also name base’s location through a symlink
(/var/folders/… for a base at /private/var/folders/…), which no strip of
base in either form removes. Its leading literal components are then
resolved, giving the same location in the base’s own spelling. Only that
prefix is rewritten and the strip consumes it, so what survives is the
pattern as written. A pattern whose first component holds a wildcard or a
brace alternation has no such prefix and stays absolute.