Skip to content

Commit 9ea2566

Browse files
authored
Update .gitattributes to prefer LF (#12816)
Part of #12387 Summary of the issue: The NVDA code base uses a mix of CRLF and LF style line endings, with the preference being CRLF. LF style endings have been introduced prior to lint checking, and can causes issues when moving code or making changes. Many IDEs will normalize the line endings when editing files, causing larger than intended diffs of files with mixed line endings. Instead, we should normalize all line endings of text files to LF and ensure that all files are committed with LF line endings. Specific files should be excluded from normalization such as: files used by translators, as we are uncertain of the side-effects here binary files git allows independent configurations between line endings used when a developer checkouts out code locally, and when code is committed to a repository. IDEs are often better suited for different line endings, with LF line endings becoming more and more standardised. However, NVDA is Windows based development, where CRLF line ending usage is commonly default or compulsory. Developers can checkout code locally, using whatever line endings they prefer or their IDE requires, using git config.core autocrlf. We can configure what line endings we commit to the repository with .gitattributes. This is set on a repository level. As what line endings we commit with is agnostic to what is checked out, the decision is based on what works best for the repository. Unix style line endings usage and support continues to increase on Windows and LF files. LF tends to be better supported by Unix style developer tools such as git. LF uses less data than CRLF.
1 parent 0336466 commit 9ea2566

File tree

3 files changed

+95
-8
lines changed

3 files changed

+95
-8
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Documentation: https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
2+
# Usage: git config --local blame.ignoreRevsFile .git-blame-ignore-revs
3+
14
# Normalize line endings in t2t files
25
e6a639bfe237ff7f98c4cbec2094a34ac4b879db
36
# Migrate t2t to markdown

.gitattributes

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,84 @@
33
# Every person expected to commit po files should change their personal config file as described here:
44
# https://mail.gnome.org/archives/kupfer-list/2010-June/msg00002.html
55
*.po filter=cleanpo
6+
7+
eol=lf
8+
* text=auto
9+
10+
# Files which should not be renormalized
11+
*.dic -text
12+
*.po -text
13+
14+
# Git files
15+
.gitignore text
16+
.gitattributes text
17+
CODEOWNERS text
18+
19+
# Documentation files
20+
*.md text
21+
*.txt text
22+
23+
# Scripts
24+
*.ps1 text
25+
*.bat text
26+
*.nsi text
27+
28+
# Config files
29+
*.ini text
30+
*.yml text
31+
*.robot text
32+
*.subst text
33+
Doxyfile text
34+
Makefile text
35+
36+
# Other files
37+
*.def text
38+
*.css text
39+
*.svg text
40+
41+
# Source files
42+
# ============
43+
# Python Sources
44+
*.py text diff=python
45+
*.pyw text diff=python
46+
*_sconscript text diff=python
47+
sconscript text diff=python
48+
sconstruct text diff=python
49+
# C++ Sources
50+
*.c text diff=c
51+
*.cpp text diff=cpp
52+
*.h text diff=c
53+
*.idl text diff=c
54+
*.acf text diff=c
55+
56+
# Binary files
57+
# ============
58+
# Python binary files
59+
# *.db binary
60+
# *.p binary
61+
# *.pkl binary
62+
# *.pickle binary
63+
# *.pyc binary
64+
# *.pyd binary
65+
# *.pyo binary
66+
# # Compiled C++ Object files
67+
# *.slo binary
68+
# *.lo binary
69+
# *.o binary
70+
# *.obj binary
71+
# # Precompiled C++ Headers
72+
# *.gch binary
73+
# *.pch binary
74+
# # Compiled C++ Dynamic libraries
75+
# *.so binary
76+
# *.dylib binary
77+
# *.dll binary
78+
# # Compiled C++ Static libraries
79+
# *.lai binary
80+
# *.la binary
81+
# *.a binary
82+
# *.lib binary
83+
# # C++ Executables
84+
# *.exe binary
85+
# *.out binary
86+
# *.app binary

projectDocs/dev/codingStandards.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
Python code style is enforced with the flake8 linter, see [`tests/lint/readme.md`](https://github.com/nvaccess/nvda/tree/master/tests/lint/readme.md) for more information.
44

55
### Encoding
6+
67
* Where Python files contain non-ASCII characters, they should be encoded in UTF-8.
7-
* There should be no Unicode BOM at the start of the file, as this unfortunately breaks one of the translation tools we use (`xgettext`).
8-
Instead, include this as the first line of the file, only if the file contains non-ASCII characters:
9-
```py
10-
# -*- coding: UTF-8 -*-
11-
```
12-
* This coding comment must also be included if strings in the code (even strings that aren't translatable) contain escape sequences that produce non-ASCII characters; e.g. `"\xff"`.
8+
* There should be no Unicode BOM at the start of the file, as this unfortunately breaks one of the translation tools we use (`xgettext`).
9+
Instead, include this as the first line of the file, only if the file contains non-ASCII characters:
10+
11+
```py
12+
# -*- coding: UTF-8 -*-
13+
```
14+
15+
* This coding comment must also be included if strings in the code (even strings that aren't translatable) contain escape sequences that produce non-ASCII characters; e.g. `"\xff"`.
1316
This is particularly relevant for braille display drivers.
1417
This is due to a `gettext` bug; see [comment on #2592](https://github.com/nvaccess/nvda/issues/2592#issuecomment-155299911).
15-
* New files should contain `LF` line endings, however NVDA currently uses a mix of LF and CRLF line endings.
16-
See issue [#12387](https://github.com/nvaccess/nvda/issues/12387).
18+
* Text files should be committed with `LF` line endings.
19+
Files can be checked out locally using CRLF if needed for Windows development using [git](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf).
1720

1821
### Indentation
1922
* Indentation must be done with tabs (one per level), not spaces.

0 commit comments

Comments
 (0)