1

I have to maintain an ERP-Software that uses the pdf-File ending to save text. Now I committed those files and want to see the diff. Instead I get this:

C:\_Belegformular Git-REPO>git diff --text text.PDF
Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error: Couldn't read xref table
Syntax Warning: PDF file is damaged - attempting to reconstruct xref table...
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table
Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error: Couldn't read xref table
Syntax Warning: PDF file is damaged - attempting to reconstruct xref table...
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

How do I tell git not to continue anyway? Or rather omit the entire PDF compare from the get go?

1 Answers1

1

Ok, I found it:

my portable Git has \etc.gitattributes which defines *.pdf diff=astextplain which tries to convert the .pdf to text.

As stated, this doesn't work for my files. After commenting the attribute out with #, it compares it as binary, because of the encoding being UCS-2 LE BOM, which is a topic on its own. But the encoding explains why my local *.pdf diff configuration looked like it did not work either.

  • PDF files should, it seems, not be UTF-16-LE nor UCS-2-LE. Apparently some parts can be UTF-16-BE, but not UTF-16-LE: see [this](https://stackoverflow.com/q/128162/1256452) and [this](https://stackoverflow.com/questions/35196976/after-encoding-utf-16-the-string-is-broken-if-i-want-to-use-in-itextsharp#comment58125562_35204876), for instance. – torek Mar 13 '21 at 12:42
  • read the question again. its not actually a pdf – TheDudeWithHat Mar 16 '21 at 07:44
  • for windows it's located in `C:\Program Files\Git\etc\gitattributes` – Nathan Chappell Nov 10 '21 at 12:38