git/list[1] front-page[2] threads[3] people[4] search[5] about
 

make git ignore the timestamp embedded in PDFs

From
ALAndreas Leha <andreas.leha@med.uni-goettingen.de>
Date
May 14, 2013, 13:17 UTC
Message-ID
<87y5bhn1iw.fsf@med.uni-goettingen.de>
Hi all,

how can I make git ignore the time stamp(s) in a PDF. Two PDFs that differ only in these time stamps should be considered identical.

Here is an example:
,----
| > pdfinfo some.pdf
| Title:          R Graphics Output
| Creator:        R
| Producer:       R 2.15.1
| CreationDate:   Thu Jan 24 13:43:31 2013 <==  these entries
| ModDate:        Thu Jan 24 13:43:31 2013 <==  should be ignored
| Tagged:         no
| Pages:          1
| Encrypted:      no
| Page size:      504 x 504 pts
| File size:      54138 bytes
| Optimized:      no
| PDF version:    1.4
`----
What I tried is a filter:
,----[ ~/.gitconfig ]
| [filter "pdfresetdate"]
|         clean = pdfresetdate
`----
With this filter script:
,----[ pdfresetdate ]
| #!/bin/bash
|
| FILEASARG=true
| if [ "$#" == 0 ]; then
|     FILEASARG=false
| fi
|
| if $FILEASARG ; then
|     FILENAME="$1"
| else
|     FILENAME=`mktemp`
|     cat /dev/stdin > "${FILENAME}"
| fi
|
| TMPFILE=`mktemp`
| TMPFILE2=`mktemp`
|
| ## dump the pdf metadata to a file and replace the dates
| pdftk "$FILENAME" dump_data | sed -e '{N;s/Date\nInfoValue: D:.*/Date\nInfoValue: D:19790101072619/}' > "$TMPFILE"
|
| ## update the pdf metadata
| pdftk "$FILENAME" update_info "$TMPFILE" output "$TMPFILE2"
|
| ## overwrite the original pdf
| mv -f "$TMPFILE2" "$FILENAME"
|
| ## clean up
| rm -f "$TMPFILE"
| rm -f "$TMPFILE2"
| if [ -n $FILEASARG ] ; then
|     cat "$FILENAME"
| fi
`----

This 'works' as far as the committed pdf indeed has the date reset to my default value.

However, when I re-checkout the files, they are marked modified by git.

So, my question is: How can I make git *completely* ignore the embedded date in the PDF?

Many thanks in advance for any help!

Regards, Andreas

PS: I had posted this question (without much success) here: http://stackoverflow.com/questions/16058187/make-git-ignore-the-date-in-pdf-files and with no answer on the git-users mailing list: https://groups.google.com/forum/#!topic/git-users/KqtecNa3cOc

Next: Johannes Sixt
Message 1 of 5 in “make git ignore the timestamp embedded in PDFs”
  1. Andreas LehaMay 14, 2013
  2. Johannes SixtMay 14, 2013
  3. Andreas LehaMay 18, 2013
  4. Johannes SixtMay 18, 2013
  5. Andreas LehaMay 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.