9

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.

Mircea Ispas
  • 20,260
  • 32
  • 123
  • 211
  • I dont think perforce has anything to do with it. You said your project was on a Mac. Probably your MAC text editors saved the files with MAC line endings which you checked in to perforce. Now if you sync them on windows they will come out unchanged - in original Mac format. You need need to think about what format you prefer - Windows or Mac? and then check in your files appropriately. – d-live Apr 14 '11 at 13:55
  • 1
    The line endings are ok, the project was created on PC and copied on Mac just to make it compile. I never changed most of the files on Mac. – Mircea Ispas Apr 14 '11 at 14:01
  • @d-live I am having a similar problem to OP right now. It appears that Perforce does change your line endings itself, and depending on its settings it does so both when you submit files and also when you get them out. – Loduwijk Oct 18 '19 at 18:08

3 Answers3

8

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.

Mark
  • 10,022
  • 2
  • 38
  • 41
  • 3
    Perforce's line ending handling is outright broken. None of its modes do what is described in the perforce documentation. In many cases the behaviour is to turn "CRLF" into "CRCRLF" – Richard1403832 Jan 15 '18 at 14:10
  • I tried to summarize the (confusing) documentation, please help review: https://stackoverflow.com/questions/10721294/setting-perforce-line-endings/53491975 – MarcH Nov 27 '18 at 02:43
1

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

Community
  • 1
  • 1
Craig
  • 456
  • 4
  • 5
-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

olan
  • 3,568
  • 5
  • 24
  • 30
  • 1
    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. – Mircea Ispas Apr 14 '11 at 13:59
  • Yeah, sorry. Just read "Perforce processes all text files using Unix-style LF line-endings." Are you using a perforce version > 2001.1 ? Have you checked to see what your p4 client "LineEnd" value is? – olan Apr 14 '11 at 14:06
  • My -1 is because the only part of this answer that is correct is "Line endings on UNIX, PC and Mac machines are all different." The rest of it is wrong. There is a Perforce setting that causes it to process all text files with unix endings, but there are other settings also. – Loduwijk Oct 18 '19 at 18:12