While setting up Git for a project, I've noticed that the line-ending normalization works a bit different on Linux and on Windows.
As I understand the Git documentation on this subject, the behavior on Windows is the correct one. Specifically, when a .gitattributes
file is present, it should override the core.autocrlf
setting.
The following table shows the results of some experimentation I've done. The two left-most columns shows the .gitattributes
file and the core.autocrlf
setting. The other columns shows the result of the following git
commands:
git rm --cached <file>
(force next checkout to perform line normalization handling).git checkout HEAD -- <file>
(checkout the file, applying line ending normalization)git ls-files --eol <file>
(check the line endings in the working tree)
+----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | .gitattributes | core.autocrlf | Linux 2.7.2 | Linux 2.11.0 | Linux 2.16.2 | Windows 2.12.2.windows.2 | Windows 2.16.1.windows.1 | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | None | true | w/crlf | w/crlf | w/crlf | w/crlf | w/crlf | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | None | false | w/lf | w/lf | w/lf | w/lf | w/lf | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | * text=auto | true | w/crlf | w/crlf | w/crlf | w/crlf | w/crlf | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | * text=auto | false | w/lf | w/lf | w/lf | w/crlf | w/crlf | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | * text=auto | true | w/crlf | w/crlf | w/crlf | w/crlf | w/crlf | | test text | | | | | | | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+ | * text=auto | false | w/lf | w/lf | w/lf | w/crlf | w/crlf | | test text | | | | | | | | | | | | | | | +----------------+---------------+-------------+--------------+--------------+--------------------------+--------------------------+
As you can see, on Linux, it seems that the core.autocrlf
settings has effect, even when a .gitattributes
file is present.
I'd like some help to determine whether this is actually a bug.