Skip to content

chore: add .gitattributes enforcing LF line endings - #594

Merged
ajitpratap0 merged 1 commit into
mainfrom
chore/gitattributes-lf
Oct 13, 2026
Merged

ajitpratap0 merged 1 commit into
mainfrom
chore/gitattributes-lf

Conversation

@ajitpratap0

Copy link
Copy Markdown
Owner

Summary

Git on the windows-latest CI runner has core.autocrlf=true, so without a .gitattributes it checks text files out with CRLF. Any test that compares a checked-in fixture byte-for-byte, or hashes fixture contents, then passes on macOS/Linux and fails only on Windows. PR #588 hit this with pkg/sql/ast/testdata/visit_order.golden, and the tokenizer golden corpus coming in the #548 PR hashes 40 corpus .sql files.

This adds a repo-wide policy:

  • * text=auto eol=lf: every file git detects as text is checked out and committed with LF on every platform.
  • Explicit LF for .go, go.mod/go.sum, .golden, .sql, .json and .sh.
  • Explicit binary for images, fonts, .wasm, .pdf and archives so they are never converted.

The two PRs above also normalize CRLF on the test side; that stays as belt and braces for anyone cloning with an unusual local config.

Test Plan

  • git ls-files --eol on main reports no tracked file with CRLF or mixed endings, and there are no .bat/.cmd/.ps1 files, so git add --renormalize . with this file in place changes nothing (verified: zero files staged besides .gitattributes).
  • git check-attr text eol -- <golden> <corpus .sql> <.go> resolves to text: set, eol: lf; .png/.ico resolve to binary.
  • Behaviour change is limited to fresh checkouts on Windows, which will now receive LF files; no Go code or CI configuration changes.

Breaking Changes

None. Contributors on Windows who already have CRLF working copies may see git report those files as modified until they re-checkout (git rm --cached -r . && git reset --hard); committed content is unaffected.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UZSk1292jPc8ipDboNxeve

Git on the windows-latest CI runner has core.autocrlf=true, so without a
.gitattributes it checks text files out with CRLF. Byte-exact golden
comparisons and content-hashed fixtures then pass on macOS/Linux and fail
only on Windows: PR #588 hit this with pkg/sql/ast/testdata/visit_order.golden,
and the #548 tokenizer golden corpus hashes 40 corpus .sql files.

Set `* text=auto eol=lf` repo-wide, pin Go sources, module files, fixtures
and shell scripts to LF explicitly, and mark image/font/wasm/archive
assets binary. No tracked file currently has CRLF endings
(`git ls-files --eol` reports none) and the repo has no Windows scripts,
so `git add --renormalize .` changes nothing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UZSk1292jPc8ipDboNxeve
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gosqlx-website Ready Ready Preview Oct 13, 2026 6:00am UTC

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 13s —— View job


Review of PR #594: .gitattributes enforcing LF

Verdict: LGTM. The change is small, correct, and low risk.

  • Read .gitattributes
  • Review

What's good

  • * text=auto eol=lf is the right baseline. Git still detects binaries itself, and text files get LF on every platform.
  • The explicit binary entries for images, fonts, .wasm, .pdf and archives guard against misdetection. The .wasm entry matters for the playground.
  • The comments explain why the file exists, and your test plan checks that --renormalize changes nothing.

Minor suggestions (non-blocking)

  1. More binary extensions. Consider adding *.tar, *.tgz, *.7z, *.svgz, *.db/*.sqlite, and *.webp/*.avif. With text=auto these would normally be detected as binary anyway, so this is only extra safety.
  2. Windows-only scripts. There are none today. If .bat, .cmd or .ps1 files are added later, they will need eol=crlf. A one-line comment would help future contributors.
  3. Redundant rules. *.go, go.mod and *.sh are already covered by * text=auto eol=lf. They are harmless and act as documentation. Dropping text from *.sql and *.json would not change anything either.
  4. Fixtures with intentional CRLF. eol=lf on *.sql means a test that needs CRLF input, such as a tokenizer line-ending test, cannot rely on a checked-in file. It must build the input in code. A grep of testdata for \r found none today, so this is only a heads-up. If one is needed later, add -text for that path.
  5. Optional: linguist-generated. Not needed here.

Other checks

Safe to merge as is.
· branch chore/gitattributes-lf

@ajitpratap0
ajitpratap0 merged commit c0bb385 into main Oct 13, 2026
28 checks passed

This branch was successfully deployed

1 active deployment
Preview — 27a2bde1 Deployed Oct 13, 2026 by vercel[bot]
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