So, I can import from p4 using git-p4 without any problem. Everything seems to work, but my PNG files (and perhaps others) are getting corrupted.
I've read about gitattributes and the line ending issues, but nothing I do seems to change the end result. Broken images.
My attributes file is: *.png binary
Any ideas? As I understand it, git is supposed to be smart enough to figure out that a png is a binary file without this help.
Is this something particular to do with how p4-git pulls the files out of Perforce?
Update: This is on Windows. I forgot that would be important.
-
The PNG file format has a header which is specifically designed to look out for programs that do end conversion, and cause a failure if not.
The 8-bytes of a PNG file are: 89 50 4E 47 0D 0A 1A 0A, chosen specifically because they contain the Unix newline and the Windows newline - so programs doing auto-conversion will automatically invalidate the PNG. PNG Signature rationale
So it seems that this is indeed the problem; and rather than assuming that Git is the problem, try looking at the import from Perforce. Either Perforce is doing the translation, or it was initially checked in in a corrupted state, and no amount of cloning/updating will fix the original problem.
: I agree - and I did take this line of thinking last night. I dug through the git-p4 source and docs to see how it pulled files out of Perforce. Turns out it just does a p4 print //path//to//file#revision So, I tries this on the PNG files and they look fine. (Also, the files as checked in are fine. These aren't new by any means.) My current guess is the way the stream is read and written inside of the Python script is doing some kind of damage. (git-p4 is a python script). But, I see no reports of this anywhere else. Makes me think it's something else in my setup.From AlBlue -
There are multiple layers of (very) leaky abstraction here.
Firstly, there is what the perforce server may be storing the files as. Secondly, the perforce client may be mangling newlines. Thirdly, the python script may be mangling newlines (Unlikely). Fourthly, git could be mangling newlines.
Now, on windows, and only on windows, git will automatically mangle newlines by default. (99% of the git community seem to hate this default, but it's apparently the only sensible default option on windows).
As a result is that if you have newline "issues", I suggest manually investigating each layer and specifying exactly how you want newlines to be treated. I suggest making them explicit, not automatic.
I suggest you investigate git's configuration first, as the windows defaults are quite different, and git's defaults differ between some versions, and some builds. (ie, msysgit is different to cygwin - cygwin's git has another layer of newline mangling - cygwin itself).
Enjoy.
From Arafangion -
Make sure your PNG file is set to "binary" type in Perforce. I just had this problem with a random binary file being set to a "text" type in Perforce. I'm not sure why Perforce had derived that file to be text, but it was causing issues with git-p4's detection of what to do with that file.
From Jimmy2Times
0 comments:
Post a Comment