ignore: handle escaped trailing whitespace#5095
Merged
Merged
Conversation
The stripping of trailing spaces currently happens as part of `git_attr_fnmatch__parse`. As we aren't currently parsing trailing whitespaces correct in case they're escaped, we'll have to change that code, though. To make actual behavioural change easier to review, refactor the code up-front by pulling it out into its own function that is expected to retain the exact same functionality as before. Like this, the fix will be trivial to apply.
Member
Author
|
@ethomson: I first thought that the things you discovered were weird. But this "foo \ " being treated as "foo" tops it all |
Member
Author
|
I take that back. Seems like I just failed to use git-check-ignore correctly. Embarassing :/ Will amend |
The gitignore's pattern format specifies that "Trailing spaces
are ignored unless they are quoted with backslash ("\")". We do
not honor this currently and will treat a pattern "foo\ " as if
it was "foo\" only and a pattern "foo\ \ " as "foo\ \".
Fix our code to handle those special cases and add tests to avoid
regressions.
0cc0cd4 to
d81e786
Compare
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.
The gitignore's pattern format specifies that "Trailing spaces
are ignored unless they are quoted with backslash ("")". We do
not honor this currently and will treat a pattern "foo\ " as if
it was "foo" only and a pattern "foo\ \ " as "foo\ ".
The current gitignore format does offer some very special
surprises, though: given a pattern "foo \ ", upstream git will in
fact strip all spaces and treat it as "foo", only.
Fix our code to handle those special cases and add tests to avoid
regressions.