Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 files 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.

like image 419
Philip Oakley Avatar asked Oct 24 '22 04:10

Philip Oakley


1 Answers

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

like image 197
manojlds Avatar answered Oct 27 '22 09:10

manojlds