Skip to content

Force LF line endings on patch/diff files via .gitattributes#258

Merged
tedwaine merged 1 commit into
AcademySoftwareFoundation:developfrom
bdeluca:pr/gitattributes-lf-on-patches
May 27, 2026
Merged

Force LF line endings on patch/diff files via .gitattributes#258
tedwaine merged 1 commit into
AcademySoftwareFoundation:developfrom
bdeluca:pr/gitattributes-lf-on-patches

Conversation

@bdeluca
Copy link
Copy Markdown
Contributor

@bdeluca bdeluca commented May 27, 2026

Summary

On Windows the default git config (core.autocrlf=true) converts text files to CRLF on checkout. git apply — used by the vcpkg overlay-port mechanism — rejects CRLF in diff hunk headers with corrupt patch at line N, breaking any vcpkg port that applies a patch as part of its build.

Adding a top-level .gitattributes that forces eol=lf on *.patch and *.diff makes those files check out with LF regardless of host autocrlf setting, so git apply works on every platform without per-developer git config.

The * text=auto line preserves git's normal text-file handling for everything else; only .patch and .diff get the explicit LF requirement.

Linux / macOS impact

None.

Windows clones with the default core.autocrlf=true convert .patch
files to CRLF on checkout. git apply (used by vcpkg overlay ports)
rejects CRLF in diff hunk headers ("corrupt patch at line N"),
breaking vcpkg builds. Forcing eol=lf on *.patch and *.diff makes
the working-tree files LF regardless of host autocrlf setting,
so the patch step works on every platform without per-developer
git config.

See hydralab issue AcademySoftwareFoundation#36.

Signed-off-by: Ben de Luca <bdeluca@gmail.com>
@bdeluca bdeluca force-pushed the pr/gitattributes-lf-on-patches branch from c9519f7 to 7176da5 Compare May 27, 2026 12:13
@tedwaine tedwaine merged commit bbce83d into AcademySoftwareFoundation:develop May 27, 2026
2 of 3 checks passed
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.

2 participants