Commit 67fa0be
committed
Ensure single trailing newline in source files
Reduce future code churn by gating source files with a test that ensures
tracked text files in the repository end with a single trailing newline
(UNIX convention).
Alternatives to enforce this without a test:
An .editorconfig file at the root of the repository makes most editors
automatically insert a final newline and trim trailing whitespace on
save, preventing the problem at the source:
root = true
[*]
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
A .gitattributes file makes Git itself flag whitespace issues in diffs,
on apply, and on merge:
* text=auto eol=lf whitespace=blank-at-eol,blank-at-eof
Both files support per-path exceptions. In .editorconfig, a section like
[*.png] can override any setting. In .gitattributes, paths can opt out
with -whitespace or be marked as binary (e.g. "*.png binary").1 parent 51fac60 commit 67fa0be
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments