Skip to content

fix: add .gitattributes so Windows checkouts do not corrupt binary maps - #4771

Open
eastwoodgrant wants to merge 1 commit into
openfrontio:mainfrom
eastwoodgrant:fix/4601-gitattributes
Open

fix: add .gitattributes so Windows checkouts do not corrupt binary maps#4771
eastwoodgrant wants to merge 1 commit into
openfrontio:mainfrom
eastwoodgrant:fix/4601-gitattributes

Conversation

@eastwoodgrant

Copy link
Copy Markdown
Contributor

Resolves #4601

Problem

The repo had no .gitattributes, so on a default Windows clone (core.autocrlf=true, the Git for Windows installer default) checkout applied LF→CRLF conversion to binary map .bin data: every 0x0A byte gained a 0x0D prefix, the file no longer matched width*height, and the game crashed on map load.

Fix

Add a .gitattributes marking binary asset types (map data, images, audio, fonts) as binary (a macro for -text -diff), so Git checks them out verbatim on every platform. Deliberately scoped to binaries only — no * text=auto, to avoid renormalizing existing text files.

Verification

  • git check-attr -a on a .bin reports binary: set, text: unset (verbatim); .svg/.ts remain unaffected.
  • Adding the file produces no renormalization of existing tracked files.
  • Note: the corruption is Windows-specific (autocrlf=true), so it was verified via git check-attr rather than a Windows checkout.

Discord: granster9

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a2a9ce79-ba2d-4097-a52b-4d9773106b81

📥 Commits

Reviewing files that changed from the base of the PR and between 845d6b1 and 490b27b.

📒 Files selected for processing (1)
  • .gitattributes

Walkthrough

Added a root .gitattributes file that marks map data, images, audio, and font formats as binary, disabling Git text and EOL handling for these assets.

Changes

Binary asset handling

Layer / File(s) Summary
Binary asset attributes
.gitattributes
Marks .bin, image, audio, and font file extensions as binary so Git treats them as binary assets.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: celant, developingtom, evanpelle

Poem

Binaries stand, bytes in flight,
Git keeps each asset right.
Maps and images, sound and font,
Cross-platform checkouts do what they ought.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: adding .gitattributes to protect Windows checkouts from binary map corruption.
Description check ✅ Passed The description matches the patch and explains the problem, fix, and verification steps.
Linked Issues check ✅ Passed The change adds a root .gitattributes for binary assets, matching issue #4601's goal to stop checkout-time corruption.
Out of Scope Changes check ✅ Passed The PR is limited to the .gitattributes file and does not introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Without a .gitattributes, a default Windows clone (core.autocrlf=true,
the Git for Windows installer default) applied LF->CRLF conversion to
binary map .bin data on checkout: every 0x0A byte gained a 0x0D prefix,
the file no longer matched width*height, and the game crashed on map
load. Mark binary asset types (map data, images, audio, fonts) as
`binary` so Git checks them out verbatim on every platform.

Resolves openfrontio#4601

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@eastwoodgrant
eastwoodgrant force-pushed the fix/4601-gitattributes branch from 845d6b1 to 490b27b Compare July 29, 2026 15:05
@Celant Celant added this to the Backlog milestone Jul 29, 2026
Comment thread .gitattributes
@@ -0,0 +1,30 @@
# Prevent Git's text/EOL handling from corrupting binary assets.
#
# The repo previously had no .gitattributes, so on a default Windows clone

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we remove this comment? That history is tracked in the issue and PR, I don't think we need it as a permanent comment too

@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

Windows checkouts silently corrupt map .bin files (no .gitattributes; autocrlf converts them as text)

2 participants