Skip to content

ignore: prune unrelated subtrees for literal rooted includes #10958

Open

Description

@gutenye

Context

A literal rooted include causes traversal of unrelated ignored trees:

!/projects/notes/file.txt
*

For this layout:

projects/notes/file.txt
projects/cache/deep/ignored.txt
movies/deep/ignored.txt

Syncthing correctly includes projects/notes/file.txt, but also traverses the ignored projects/cache and movies trees.

Expected behavior

Keep the required ancestors traversable while pruning unrelated ignored branches.

Cause and proposed change

The matcher disables pruning upon encountering a nested include, before checking whether that pattern could match beneath the current directory.

For literal rooted includes, compare path-component prefixes to preserve traversal of ancestors and descendants while allowing unrelated branches to be skipped. Keep conservative behavior for wildcard, escaped, and unrooted patterns.

A prepared patch implements this with regression tests.

Testing

Reproduced on v2.1.7 and current upstream main. The new tests fail before the change and pass afterward. Affected suites, race detection, Go vet, and repository metadata checks pass.

Synthetic scanner benchmark with 1,000 unrelated trees, three alternating runs:

Metric Before After Change
Visited entries 4,005 1,005 −74.9%
Median scan time 13.19 ms 2.80 ms −78.7%

These are lab measurements, not whole-home rescan timings.

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions