Repository navigation
Treat a '-' in a character group as a literal unless it is a range - #37
Open
compiler-segfault wants to merge 1 commit into
Open
compiler-segfault wants to merge 1 commit into
compiler-segfault wants to merge 1 commit into
Conversation
A '-' is a range marker only when it sits between two characters of the group. A group whose content ended with '-' indexed one byte past the end of the pattern and panicked with "index out of range"; git-lfs reaches this through `git lfs track '[a-'` and `git lfs ls-files --include='[a-'`. A '-' in the first or last position, or right after a range, is now a literal, and the character which ends a range may be escaped. A group without a closing ']' now matches nothing, as it does in git.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parseComponenttreats every-in a character group as a range marker, so a group whose content ends with-reads one byte past the end of the pattern:git lfs ls-files --include='[a-'crashes the same way on git-lfs v3.8.1, and so does[[:alpha:]-.The same branch also builds the wrong range whenever the character after the
-is not the second bound of a range:git check-ignore[a-]-[a-]][-a]][a-]xax[!a-]-[a-c-e]dThe
gitcolumn comes fromgit check-ignore --no-index --stdinin a scratch repository.This makes a
-a range marker only when it sits between two characters of the group and treats it as a literal otherwise, consumes an escaped character that ends a range ([A-\]), and makes a group without a closing]match nothing, which is what git does as well.Tests cover the panic and every row of the table above.