Skip to content

Commit a98b459

Browse files
committed
Disable Git converting line endings in files
This does the same as setting `core.autocrlf=false` via `git config` or a Git configuration file, but in a manner that allows that configuration to be distributed, rather than each contributor having their own settings. The immediate motivation for adding this file is as a workaround for a bug in the "actions/setup-python" action which causes it to fail spuriously when pyproject.toml is used as the Python versioning source and that file has CRLF line endings: ```text Error: Control characters (codes < 0x1f and 0x7f) are not allowed in comments, use \u000d instead at row 10, col 34, pos 211: 9: 10> # Integration tests dependencies. ^ 11: invoke = "^2.2.0" ``` The GitHub Actions Windows runners hosted by GitHub have `core.autocrlf=false` in their Git configuration, which causes the "actions/checkout" action step in a workflow to convert the repo's LF line endings to CRLF if the workflow runs on a Windows runner. A fix for the "actions/setup-python" action bug has already been made, so this would no longer be a problem once the next release of the action comes out. However, the conversion of line endings by Git is utterly pointless because any tool suitable for development work will have absolutely no problem working with LF line endings. The files in the project have the line endings they do for a reason and Git should not ever modify them. So the addition of this file has the ongoing benefit of ensuring Git won't be configured for the annoying and potentially harmful line ending conversion on the contributor's machine.
1 parent 51ab9b2 commit a98b459

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: .gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# See: https://git-scm.com/docs/gitattributes
2+
3+
# Disable Git converting line endings in files (i.e., core.autocrlf=true).
4+
* -text

0 commit comments

Comments
 (0)