Skip to content

Conversation

@mikexstudios
Copy link
Contributor

The git client (tested with v2.4.1) exhibits differing behavior than pathspec's GitIgnorePattern, including:

  • / does NOT match all paths the repo
  • /abs/path matches: abs/path/foo
  • spam matches: spam/, spam/foo
  • spam/two does NOT match: foo/spam/two
  • spam/** does NOT match: foo/spam/bar
  • left/**/right does NOT match: foo/left/bar/right
  • **/spam does match: foo/spam/, foo/spam/bar
  • foo-*-bar does match: foo-hello-bar/baz
  • ~temp-* does match: ~temp-foo/bar
  • *.py does match: bar.py/baz

Tests for each of these cases have been added. While some of these edge cases may be bugs in git, until they are fixed, I believe that pathspec should handle .gitignore files as close as possible to how git handles them. I marked these edge cases with EDGE CASE comments so that they can be easily removed in the future.

More complex behavior, such as an include pattern followed by an exclude pattern were not tested since they would involve integration tests.

Thank you so much for creating this library!

The git client (tested with v2.4.1) exhibits differing behavior than
pathspec's GitIgnorePattern, including:

- `/` does NOT match all paths the repo
- `/abs/path` matches: `abs/path/foo`
- `spam` matches: `spam/`, `spam/foo`
- `spam/two` does NOT match: `foo/spam/two`
- `spam/**` does NOT match: `foo/spam/bar`
- `left/**/right` does NOT match: `foo/left/bar/right`
- `**/spam` does match: `foo/spam/`, `foo/spam/bar`
- `foo-*-bar` does match: `foo-hello-bar/baz`
- `~temp-*` does match: `~temp-foo/bar`
- `*.py` does match: `bar.py/baz`

Tests for each of these cases have been added. While some of these edge
cases may be bugs in git, until they are fixed, I believe that pathspec
should handle .gitignore files as close as possible to how git handles
them.

More complex behavior, such as an include pattern followed by an exclude
pattern were not tested since they would involve integration tests.
@cpburnz
Copy link
Owner

cpburnz commented May 16, 2015

Thank you for finding out these edge cases and taking the time to fix them. I guess git's pattern matching is more complicated than I realized.

cpburnz added a commit that referenced this pull request May 16, 2015
Fixes for handling .gitignore edge cases in GitIgnorePattern.
@cpburnz cpburnz merged commit a52ccec into cpburnz:master May 16, 2015
@mikexstudios
Copy link
Contributor Author

Thank you!

jdpace added a commit to jdpace/pathspec-ruby that referenced this pull request May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants