Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-p4 is eating my image files

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.

like image 450
Christopher Manley Avatar asked Feb 27 '23 23:02

Christopher Manley


1 Answers

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.

like image 57
AlBlue Avatar answered Mar 08 '23 00:03

AlBlue