2

Just moved to git and encountered a problem which has been discussed in detail here

I wanted to understand given that we have set core.autocrlf=true by default and we deal with vast amount of java i/o and consequently have various test cases for the same ; how can we ensure that unit test cases developed by a dev on win can execute correctly for a dev on linux and vice versa.

for eg. a unit test case reads in a text file (*.ext) and compares the length of the bytes as expected vs actual then on win ; a git pull with core.autocrlf=true will have pulled in the text file and converted all LF to CRLF . Consider for instance the test case is interested in the byte count and thus on win the byte count will be more. On commit the CRLF wud be converted to LF ; but the test wud then fail for the dev on linux.

Can this managed with .gitattributes ?

In .gitattributes -> *.ext text

this would normalize the file on commit and will still suffer from the above problem ? Pointers welcome, Thanks in advance

4

1 回答 1

1

正如我之前所说,永远不要设置core.autocrlf为 true ,总是设置为 false

这是一个具有意想不到后果的全球环境。

如果您有特定类型的文档要根据 eol 进行管理,请仅通过.gitattributesfiles 和core.eoldirectives进行。

在您的情况下,gitattributes这是一个很好的解决方案,以便对您想要转换的内容进行细粒度控制。

但是一般的想法是在绝对必要之前不要转换任何东西:
如果您可以使用正确的 eol(无论底层操作系统是什么)生成或存储那些文本文件(用于测试),那么您的测试用例将是一致的。

于 2013-09-11T05:32:44.160 回答