Repository navigation
Skip a UTF-8 BOM at the start of an ignore file - #37
Conversation
A .gitignore saved with a byte order mark kept the mark as part of its first line, so "*.log" turned into a pattern that starts with the mark and never matched. git skips the mark before splitting lines (skip_utf8_bom, called from add_patterns_from_buffer in dir.c), so the first pattern works there. Trim it in addPatterns, which covers files and AddPatterns alike. A mark anywhere else is still part of its pattern, as in git. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Thanks for this, the fix matches what I see from git 2.56.0 here too. I'm curious about the differential run you mentioned. Which implementations did you compare, and how were the patterns and paths generated (hand-written cases, fuzzing, real-world Did it turn up any other places where this library disagrees with |
|
Thanks for merging, Andrew. Answers to your questions: Harness. It's public now: https://github.com/AbuYahya94/gitignore-differential. It was built and run by AI coding agents (Claude) that I directed, so please treat the results as leads to confirm. Each named case was re-run with a separately written checker ( What was compared. git 2.56.1 as the reference, against 19 projects: Apple git 2.50.1, ripgrep, fd, the How cases were generated. 20,000 seeded cases from a small grammar biased toward the subtle features, plus 298 corpus cases (170 from This library. v1.3.0 differed from git on 348 of 20,298 cases (1.7%), which reduce to 95 minimal vectors. 75 of those were the BOM case this PR fixed. The other 20 were re-checked against
I have these as six cases in the |
A
.gitignoresaved with a UTF-8 byte order mark kept the mark as part of its first line, so*.logturned into a pattern that starts with the mark and never matched.Reproduce
.gitignore=<BOM>*.log:x.logis not ignored by this package;git check-ignore x.logsays it is.Why
Git skips the mark before splitting lines:
skip_utf8_bom, called fromadd_patterns_from_bufferindir.c.Change
Trim the mark in
addPatterns, which covers files andAddPatternsalike. A mark anywhere else is still part of its pattern, as in git.Testing
git check-ignore.go test -race ./...: 220 of 220 pass.golangci-lint: 0 issues.Found by a differential run of ignore implementations against Git 2.56.1. Prepared with AI assistance (Claude) and reviewed by me.
🤖 Generated with Claude Code