]> git.ipfire.org Git - thirdparty/git.git/commit - git-p4.py
git p4: scrub crlf for utf16 files on windows
authorPete Wyckoff <pw@padd.com>
Sun, 27 Jan 2013 03:11:13 +0000 (22:11 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jan 2013 06:00:39 +0000 (22:00 -0800)
commit7f0e596276aa120059b0f2df235a8ba1cb9b2554
tree7e4c011d298509831d7c1caaaf8eea8206424e81
parentbb5ea62d80313f6fd37f3f3c214c78feb34036f9
git p4: scrub crlf for utf16 files on windows

Files of type utf16 are handled with "p4 print" instead of the
normal "p4 -G print" interface due to how the latter does not
produce correct output.  See 55aa571 (git-p4: handle utf16
filetype properly, 2011-09-17) for details.

On windows, though, "p4 print" can not be told which line
endings to use, as there is no underlying client, and always
chooses crlf, even for utf16 files.  Convert the \r\n into \n
when importing utf16 files.

The fix for this is complex, in that the problem is a property
of the NT version of p4.  There are old versions of p4 that
were compiled directly for cygwin that should not be subjected
to text replacement.  The right check here, then, is to look
at the p4 version, not the OS version.  Note also that on cygwin,
platform.system() is "CYGWIN_NT-5.1" or similar, not "Windows".

Add a function to memoize the p4 version string and use it to
check for "/NT", indicating the Windows build of p4.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py