Skip to content

Parse ignore files without the scanner line limit - #31

Merged
andrew merged 1 commit into
mainfrom
fix-long-ignore-lines
Sep 13, 2026
Merged

Parse ignore files without the scanner line limit#31
andrew merged 1 commit into
mainfrom
fix-long-ignore-lines

Conversation

@andrew

@andrew andrew commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Ignore files with a line longer than the scanner limit silently lost every later rule, even when that line was a comment. Iterate over the loaded bytes so all lines are parsed, preserving CRLF handling and source line numbers.

Adds regression coverage against Git for long patterns and comments through AddPatterns, AddFromFile, and New.

Fixes #28.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Preserve lone-CR-terminated patterns by stripping \r only when it follows a newline.

Pull request overview

This PR updates ignore-file parsing to support lines exceeding the scanner limit while preserving line metadata and newline handling.

Changes:

  • Replaces scanner-based parsing with byte-based iteration.
  • Adds regression tests and benchmarks for long lines, comments, CRLF, and loading paths.
File summaries
File Summary
long_lines_test.go Adds long-line regression coverage and benchmarks.
gitignore.go Implements unrestricted byte-based parsing. Moderate issue (1 vote): trailing \r is removed from final lines without \n, changing existing behavior.
Review details

Suppressed comments (1)

gitignore.go:438

  • This unconditionally removes a trailing \r, including when the input's final line has no \n. That changes the existing bufio.ScanLines behavior for a lone-CR-terminated pattern (foo\r becomes foo), which can change both matching and reported pattern text. Only strip \r when bytes.Cut found a newline, i.e. for CRLF.
		raw = bytes.TrimSuffix(raw, []byte{'\r'})
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@andrew
andrew merged commit 2343e2e into main Sep 13, 2026
8 checks passed
@andrew
andrew deleted the fix-long-ignore-lines branch September 13, 2026 00:10
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.

addPatterns silently drops all patterns after a line longer than 64KB

2 participants