问题描述
我正在使用perforce来管理一些代码.我在本地计算机和Unix框上设置了一个工作区.但是最近perforce开始在行尾添加^ M个字符,这在运行unix env中的代码时引起了问题.编辑文件时,如何在本地设置我的perforce不要执行此操作.我正在使用记事本++在本地进行编辑
I'm using perforce to manage some code. I have a workspace set up on my local machine and on the unix box. However recently perforce started adding ^M characters to end of the lines which caused issue when running the code in the unix env. How can I set my perforce locally not to do this when editing files. I'm using Notepad++ to edit locally
推荐答案
我建议两个客户端都使用Unix行尾.
I'd recommend using Unix line-endings for both clients.
Unix行尾(尽管有名称)将在文件从原始提交方式同步时告知perforce客户端不修改行尾.在两个客户端上都设置了此设置后,如果您在Windows上创建文件并将其同步到Unix,它仍将具有Windows行尾,但在Unix上应该不会造成问题,并且perforce不会删除/添加字符,从而导致^ M.
Unix line endings, despite the name, will tell the perforce client not to modify the line-endings when files are synced from how it is submitted originally. With this set on both clients, if you create a file on Windows and sync it to Unix it will still have Windows line-endings but it shouldn't pose a problem on Unix and perforce won't remove/add characters which leads to the ^M.
一个小缺点是Windows机器将需要Unix行尾感知的实用程序(例如Notepad ++),但这对您来说似乎并不是一个问题.
One small disadvantage is Windows machines will need to Unix line-endings aware utilities such as Notepad++ but that doesn't sound like an issue for you.
在我们的Unix,Mac和Windows都在同一软件仓库中使用的团队环境中,我们的所有客户端都被[Unix]服务器上的一个简单的单行触发器强制为Unix行尾,因此没有人会遇到此问题(它还会强制Submitunchanged和rmdir,但您可以选择剥离这些):
In our team environment where Unix, Mac and Windows are all used on the same depot, all our clients are forced to Unix line-endings by a simple one line trigger on the [Unix] server so that nobody suffers this issue (it also forces submitunchanged and rmdir but you may choose to strip these):
clientspec form-in client "sed -i -e s/LineEnd.*/LineEnd:unix/ -e s/submitunchanged/revertunchanged/ -e s/normdir/rmdir/ %formfile%"
这篇关于设置Perforce行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!