Perforce: Keeping Perforce from altering text-file format

前端 未结 5 1243
猫巷女王i
猫巷女王i 2021-02-19 10:20

Is there a way to tell Perforce to leave text files alone without setting the file-type as binary? Or barring that, is there a way to tell the Perforce client to diff binaries?

相关标签:
5条回答
  • 2021-02-19 10:24

    Set all of your client/workspace specs to 'unix' line-endings. Then no conversion will take place when you check in on Windows.

    See http://answers.perforce.com/articles/KB_Article/CR-LF-Issues-and-Text-Line-endings/

    0 讨论(0)
  • 2021-02-19 10:27

    Give the files a different extension.

    0 讨论(0)
  • 2021-02-19 10:28

    I have just come across exactly the same problem, but have a better solution that does not involve changing client specs (which are international, and not all of which I have write access to).

    All of our clients are Windows PCs, but Cygwin is included within the Perforce Depot. Cygwin is a Windows implementation of Unix, and requires that text files use LF for line endings.

    A possible solution for older versions of Cygwin is to mount the root using the "text" option, meaning that files can have CR+LF line endings. However, on upgrading to Cygwin 1.7.9, this no longer worked, as mounts are transient unless they are written into /etc/fstab. I did not manage to make this work.

    Luckily, the Perforce Guru sitting next to me came up with the solution of changing the filetype to binary+D, which uses the same RCS incremental patch storage as text files, but without the automatic line ending conversion.

    I can diff these "text" files successfully between my local workspace and the depot.

    0 讨论(0)
  • 2021-02-19 10:34

    The Perforce client can handle line ending properly when syncing to different platforms provided you have LineEnd option set properly on your client. Perhaps you have yours set wrong? Open up your client specs and set the LineEnd option according to your needs.

    Check out this KB article on their website for more info. Here's an excerpt:

    On the server side, Perforce processes all text files using Unix-style LF line-endings. Although Perforce stores server archive files on disk in the operating system's native line termination convention (CR/LF on Windows, LF on Unix), all line-endings are normalized to Unix-style LF line-endings for internal Perforce Server operations such as p4 sync, p4 submit and p4 diff.

    On the client workspace side, Perforce handling of line-endings is determined by a global option for each clientspec. When you sync text files to a client workspace with p4 sync, or submit them back to a Perforce Server with p4 submit, their line-endings are converted as specified in the clientspec LineEnd section.

    0 讨论(0)
  • 2021-02-19 10:47

    When adding text files that you want to be considered binary to Perforce, use the command p4 add with the -t option to override the type mapping table. See the documentation here. The example given there is p4 add -t binary file.pdf.

    0 讨论(0)
提交回复
热议问题