Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Perforce line endings

Tags:

line

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

like image 972
Will Avatar asked May 23 '12 13:05

Will


1 Answers

I'd recommend using Unix line-endings for both clients.

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.

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.

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%"
like image 51
Craig Avatar answered Sep 19 '22 05:09

Craig