开发者

Not doing git CRLF conversion for .m matlab files?

Matlab .m files use the Unix LF line endings even on Windows. I'm look to set up the git config file so that the .m file开发者_StackOverflow中文版s are not converted back to CRLF as other regular text files would be (i.e. I am using LF as the default style within the repo, even though its Windows).

Can this be done?

EDIT: from Matlab 2008b manual. (under Editing and Debugging M-Files)

Line Endings Removed in Files Provided with MATLAB Software for Windows Platforms; Impacts Viewing in Notepad Application

In previous versions, text files provided with MATLAB for Windows platforms included a carriage return and line feed at the end of each line. Starting in R2007b, the text files MATLAB provides do not include a carriage return and line feed at the end of each line.

File types affected are: .asc .bat .c .cc .cdr .cpp .def .for gs.rights .h .ini .m .mdl .pl readme .tlc .tmf .txt

There is no impact if you view the files in MATLAB and other common text editors, with the known exception of the Microsoft Notepad application.

Compatibility Considerations. If you use the Notepad application to view files provided with MATLAB, you see carriage return and line feed symbols instead of line endings. This makes the files less readable in the Notepad application. Other text editors might display the symbols instead of line endings, but of the common text editors tested, none have been found that do so.

As an alternative to the Notepad application, use the Microsoft WordPad application, provided with Windows platforms, or another text editor to view the files.


Set the core.autocrlf config to false and core.eol to lf on Windows.

[core]
    autocrlf = false
    eol = lf

Also, have a look at gitattributes under Checking-out and checking-in


Change autocrlf to false. set core.whitespace to cr-at-eol (This will ensure you don't get ^M highlighted as problematic whitespace in diffs and patches). Use vim or another editor to ensure you have lfs in your .m files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜