Skip to content

[parser] Filter Git patch metadata [FCOM-16] - #1142

Merged
davidrunger merged 1 commit into
mainfrom
parser/filter-git-metadata
Aug 28, 2026
Merged

[parser] Filter Git patch metadata [FCOM-16]#1142
davidrunger merged 1 commit into
mainfrom
parser/filter-git-metadata

Conversation

@davidrunger

Copy link
Copy Markdown
Owner

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:

((\+|-)\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

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
@davidrunger
davidrunger merged commit 9d5ecc6 into main Aug 28, 2026
1 check passed
@davidrunger
davidrunger deleted the parser/filter-git-metadata branch August 28, 2026 19:17
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.

1 participant