强制更改行结尾
我在 Mac 上有一个项目并将其上传到 perforce 服务器。当我从 PC 获取该项目时,所有行结尾都已更改,现在它无法在 PC 上编译。有没有办法像以前一样自动更改行结尾,或者我必须再次从 Windows 提交所有项目?有什么方法可以强制保留我的文件原样吗?我真的不想对我的源文件进行愚蠢的修改。
谢谢!
编辑:
这与 perforce 有关,我刚刚在 MAC 上编辑了 10-20 个文件来制作一个要编译的多平台项目。其余140k文件没有改变,甚至没有在Mac上打开(它们是由编译器打开来编译的:P)。如果我将项目复制到 PC 上,行结尾就可以了。
I had a project on Mac and uploaded it to a perforce server. When I got the project from PC all the line endings were changed and now it does not compile on PC. Is there a way to automatically change the line endings like they were before or I must submit again all the project from Windows? Is there any way to make perforce to keep my files AS THEY ARE? I really don't want to have stupid modifications in my source files.
Thanks!
EDIT:
It has to do with perforce, I just edited 10-20 files on MAC to make a multiplatform project to compile. The rest of 140k files were not changed and not even opened on Mac(they were opened by compiler to compile them:P). If I copy the project on PC the line endings are ok.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
文本文件的行结尾由您的客户端规范设置控制。您需要确保客户端的“LineEnd”值设置正确。一般来说,这应该留给“本地”,它应该为您使用的任何操作系统做正确的事情。
也就是说,根据您最初上传文件时在 Mac 上设置此值的方式,我认为将这些文件同步到 PC 时可能会出现一些问题。
我会检查以确保您的客户将 LineEnd 设置为“本地”。 Perforce 知识库网站此处上有一条说明更深入地了解 Macintosh 客户端的正确设置。这也可能是一个起点,以确保您在 Macintosh 上正确配置了一些东西。
Line endings for text files are controlled by your client spec setting. You need to make sure that your client's 'LineEnd' value is set properly. In general, this should be left to 'local' which should do the right thing for whatever operating system you are using.
That said, depending on how this value was set on your Mac when you originally uploaded the files, I suppose that there could possibly be some problem when syncing those files to your PC.
I would check to make sure that LineEnd is set to 'local' for your clients. There is a note on the Perforce Knowledge Base site here that talks more in depth about proper settings for Macintosh clients. That might be a place to start as well to make sure that you have things properly configured on your Macintosh.
是的,你可以。对两个客户端使用 Unix 行结尾将告诉 perforce 客户端保留文件的提交方式不变。您还可以在服务器上设置一个触发器以强制这种方式,请参阅我对此问题的回答:
设置强制行结尾
Yes you can. Using Unix line-endings for both your clients will tell the perforce clients to leave the files unchanged from how they were submitted. You can also setup a trigger on the server to force it this way, refer to my answer to this question:
Setting Perforce line endings
尽管它确实解决了问题,但实际上与 perforce 没有任何关系。
http://kb.perforce.com/article/63
UNIX、PC 和 Mac 上的行结尾机器都是不同的。
这就是你所看到的。通过任何介质在 PC 和 Mac 之间传输相同的文件都会产生相同的结果。如果您想以另一种方式解决此问题,您可以在 Mac 上设置编辑器以保存带有 Windows 行结尾的文件。我错了“Perforce 使用 Unix 风格的 LF 行结尾处理所有文本文件”。我会检查 p4 客户端 LineEnd 值(我认为应该是两台机器上的本地值)并确保您使用的版本是 p4 >= 2001.1
This doesn't have anything to do with perforce really, although it does handle the problem.
http://kb.perforce.com/article/63
Line endings on UNIX, PC and Mac machines are all different.
This is what your seeing. Transferring the same file between PC and Mac over any medium would have the same results. You can probably set your editor on the Mac to save the file with windows line endings if you want to get around this another way.I was wrong "Perforce processes all text files using Unix-style LF line-endings". I'd check p4 client LineEnd value (should be local on both machines I think) and ensure you're using a version of p4 >= 2001.1