[parser] Filter Git patch metadata [FCOM-16] - #1142
Merged
Merged
Conversation
The `rg` stage intentionally retains lines matching the search expression plus `commit` and `diff` headers. The parser previously used an unanchored expression with an ungrouped user regex, so an alternation such as `path|file` could make hunk headers, mode and rename metadata, binary notices, and newline markers look like matching changes. The old expression looked like it required a `+` or `-`, but `expression_to_match` was interpolated without grouping. For `path|file`, interpolation produced: ```regex ((\+|-)\s?.*path|file.*|Omitted long (matching )?line) ``` Since `|` has top-level precedence and `Regexp#match?` searches for a match anywhere by default, the `file.*` alternative matched lines such as `new file mode 100755`, `rename from Gemfile.lock`, and `Binary files ...`. Hunk headers could match for the same reason, while `---`/`+++` headers also looked like changed lines because they begin with `-`/`+`. This extends 3ef8afa, which filtered `---`/`+++` file headers but left other Git metadata exposed when it matched the search expression. Anchor the parser match to the beginning of lines with a diff `+` or `-`, group the user expression, and add regression coverage for representative metadata and a real alternation match. codex resume 01a049a6-68c1-7360-90e2-13ff6064e6cb
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
rgstage intentionally retains lines matching the search expression pluscommitanddiffheaders. The parser previously used an unanchored expression with an ungrouped user regex, so an alternation such aspath|filecould make hunk headers, mode and rename metadata, binary notices, and newline markers look like matching changes.The old expression looked like it required a
+or-, butexpression_to_matchwas interpolated without grouping. Forpath|file, interpolation produced:Since
|has top-level precedence andRegexp#match?searches for a match anywhere by default, thefile.*alternative matched lines such asnew file mode 100755,rename from Gemfile.lock, andBinary files .... Hunk headers could match for the same reason, while---/+++headers also looked like changed lines because they begin with-/+.This extends 3ef8afa, which filtered
---/+++file headers but left other Git metadata exposed when it matched the search expression. Anchor the parser match to the beginning of lines with a diff+or-, group the user expression, and add regression coverage for representative metadata and a real alternation match.codex resume 01a049a6-68c1-7360-90e2-13ff6064e6cb