Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pattern with slash in range #55

Merged
merged 1 commit into from
Oct 3, 2023

Conversation

jherland
Copy link
Contributor

@jherland jherland commented Oct 3, 2023

When a slash appears in a range, it should NOT match a directory
separator.

Quoting https://git-scm.com/docs/gitignore#_pattern_format:

The range notation, e.g. [a-zA-Z], can be used to match one of the
characters in a range. See fnmatch(3) and the FNM_PATHNAME flag for
a more detailed description.

And quoting what fnmatch(3) has to say about FNM_PATHNAME:

match a slash in string only with a slash in pattern and not by an
asterisk (*) or a question mark (?) metacharacter, nor by a bracket
expression ([]) containing a slash.

Hence, it seems to me that a slash inside a range should be disregarded.

When a slash appears in a range, it should NOT match a directory
separator.

Quoting https://git-scm.com/docs/gitignore#_pattern_format:

  The range notation, e.g. [a-zA-Z], can be used to match one of the
  characters in a range. See fnmatch(3) and the FNM_PATHNAME flag for
  a more detailed description.

And quoting what fnmatch(3) has to say about FNM_PATHNAME:

  match a slash in string only with a slash in pattern and not by an
  asterisk (*) or a question mark (?) metacharacter, nor by a bracket
  expression ([]) containing a slash.

Hence, it seems to me that a slash inside a range should be disregarded.
@mherrmann mherrmann merged commit d45a085 into mherrmann:master Oct 3, 2023
5 checks passed
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