{"thread":{"id":"33817","subject":"make git ignore the timestamp embedded in PDFs","startedAt":"2013-05-14T13:17:59Z","lastAt":"2013-05-18T18:09:38Z","messageCount":5,"participants":["Andreas Leha","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"217326","messageId":"87y5bhn1iw.fsf@med.uni-goettingen.de","threadId":"33817","inReplyTo":null,"subject":"make git ignore the timestamp embedded in PDFs","fromName":"Andreas Leha","fromEmail":"andreas.leha@med.uni-goettingen.de","sentAt":"2013-05-14T13:17:59Z","receivedAt":"2013-05-14T13:17:59Z","isPatch":false,"sender":{"key":"andreas.leha@med.uni-goettingen.de","avatar":null},"body":"Hi all,\n\nhow can I make git ignore the time stamp(s) in a PDF.  Two PDFs that\ndiffer only in these time stamps should be considered identical.\n\nHere is an example:\n,----\n| > pdfinfo some.pdf\n| Title:          R Graphics Output\n| Creator:        R\n| Producer:       R 2.15.1\n| CreationDate:   Thu Jan 24 13:43:31 2013 <==  these entries\n| ModDate:        Thu Jan 24 13:43:31 2013 <==  should be ignored\n| Tagged:         no\n| Pages:          1\n| Encrypted:      no\n| Page size:      504 x 504 pts\n| File size:      54138 bytes\n| Optimized:      no\n| PDF version:    1.4\n`----\n\n\nWhat I tried is a filter:\n,----[ ~/.gitconfig ]\n| [filter \"pdfresetdate\"]\n|         clean = pdfresetdate\n`----\n\nWith this filter script:\n,----[ pdfresetdate ]\n| #!/bin/bash\n|\n| FILEASARG=true\n| if [ \"$#\" == 0 ]; then\n|     FILEASARG=false\n| fi\n|\n| if $FILEASARG ; then\n|     FILENAME=\"$1\"\n| else\n|     FILENAME=`mktemp`\n|     cat /dev/stdin > \"${FILENAME}\"\n| fi\n|\n| TMPFILE=`mktemp`\n| TMPFILE2=`mktemp`\n|\n| ## dump the pdf metadata to a file and replace the dates\n| pdftk \"$FILENAME\" dump_data | sed -e '{N;s/Date\\nInfoValue: D:.*/Date\\nInfoValue: D:19790101072619/}' > \"$TMPFILE\"\n|\n| ## update the pdf metadata\n| pdftk \"$FILENAME\" update_info \"$TMPFILE\" output \"$TMPFILE2\"\n|\n| ## overwrite the original pdf\n| mv -f \"$TMPFILE2\" \"$FILENAME\"\n|\n| ## clean up\n| rm -f \"$TMPFILE\"\n| rm -f \"$TMPFILE2\"\n| if [ -n $FILEASARG ] ; then\n|     cat \"$FILENAME\"\n| fi\n`----\n\n\nThis 'works' as far as the committed pdf indeed has the date reset to my\ndefault value.\n\nHowever, when I re-checkout the files, they are marked modified by git.\n\nSo, my question is:  How can I make git *completely* ignore the embedded\ndate in the PDF?\n\nMany thanks in advance for any help!\n\nRegards,\nAndreas\n\n\nPS:\nI had posted this question (without much success) here:\nhttp://stackoverflow.com/questions/16058187/make-git-ignore-the-date-in-pdf-files\nand with no answer on the git-users mailing list:\nhttps://groups.google.com/forum/#!topic/git-users/KqtecNa3cOc\n"},{"id":"217355","messageId":"51928FE8.2050804@kdbg.org","threadId":"33817","inReplyTo":"87y5bhn1iw.fsf@med.uni-goettingen.de","subject":"Re: make git ignore the timestamp embedded in PDFs","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2013-05-14T19:26:32Z","receivedAt":"2013-05-14T19:26:32Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 14.05.2013 15:17, schrieb Andreas Leha:\n> Hi all,\n> \n> how can I make git ignore the time stamp(s) in a PDF.  Two PDFs that\n> differ only in these time stamps should be considered identical.\n> ...\n> What I tried is a filter:\n> ,----[ ~/.gitconfig ]\n> | [filter \"pdfresetdate\"]\n> |         clean = pdfresetdate\n> `----\n> \n> This 'works' as far as the committed pdf indeed has the date reset to my\n> default value.\n> \n> However, when I re-checkout the files, they are marked modified by git.\n\nI'm using cleaned files every now and then, but not on Linux. I have\nnever observed this behavior recently.\n\nIf you 'git add' the file, does it keep its modified state? Does 'git\ndiff' tell a difference?\n\n-- Hannes\n"},{"id":"217795","messageId":"87ppwohgyd.fsf@med.uni-goettingen.de","threadId":"33817","inReplyTo":"51928FE8.2050804@kdbg.org","subject":"Re: make git ignore the timestamp embedded in PDFs","fromName":"Andreas Leha","fromEmail":"andreas.leha@med.uni-goettingen.de","sentAt":"2013-05-18T07:42:34Z","receivedAt":"2013-05-18T07:42:34Z","isPatch":false,"sender":{"key":"andreas.leha@med.uni-goettingen.de","avatar":null},"body":"Hi Hannes,\n\nthanks for taking this up and sorry for the long delay in my answer.\n\nJohannes Sixt <j6t@kdbg.org> writes:\n\n> Am 14.05.2013 15:17, schrieb Andreas Leha:\n>> Hi all,\n>> \n>> how can I make git ignore the time stamp(s) in a PDF.  Two PDFs that\n>> differ only in these time stamps should be considered identical.\n>> ...\n>> What I tried is a filter:\n>> ,----[ ~/.gitconfig ]\n>> | [filter \"pdfresetdate\"]\n>> |         clean = pdfresetdate\n>> `----\n>> \n>> This 'works' as far as the committed pdf indeed has the date reset to my\n>> default value.\n>> \n>> However, when I re-checkout the files, they are marked modified by git.\n>\n> I'm using cleaned files every now and then, but not on Linux. I have\n> never observed this behavior recently.\n>\n> If you 'git add' the file, does it keep its modified state? Does 'git\n\nyes.\n\n> diff' tell a difference?\n\nno.\n\nHere is a complete 'session':\n,----\n| > mkdir test\n| > cd test\n| > git init\n| > echo '*.pdf filter=pdfresetdate' > .gitattributes\n| > cp ~/PDF/score_table.pdf .\n| > pdfinfo score_table.pdf\n| Title:          (score_table)\n| Author:         (andreas)\n| Creator:        GPL Ghostscript 905 (ps2write)\n| Producer:       GPL Ghostscript 9.05\n| CreationDate:   Fri Feb  8 15:44:47 2013\n| ModDate:        Fri Feb  8 15:44:47 2013\n| Tagged:         no\n| Pages:          1\n| Encrypted:      no\n| Page size:      595 x 842 pts (A4)\n| File size:      36989 bytes\n| Optimized:      no\n| PDF version:    1.4\n| > git add score_table.pdf\n| > pdfinfo score_table.pdf\n| Title:          (score_table)\n| Author:         (andreas)\n| Creator:        GPL Ghostscript 905 (ps2write)\n| Producer:       GPL Ghostscript 9.05\n| CreationDate:   Fri Feb  8 15:44:47 2013\n| ModDate:        Fri Feb  8 15:44:47 2013\n| Tagged:         no\n| Pages:          1\n| Encrypted:      no\n| Page size:      595 x 842 pts (A4)\n| File size:      36989 bytes\n| Optimized:      no\n| PDF version:    1.4\n| > git commit -m \"test\"\n| > pdfinfo score_table.pdf\n| Title:          (score_table)\n| Author:         (andreas)\n| Creator:        GPL Ghostscript 905 (ps2write)\n| Producer:       GPL Ghostscript 9.05\n| CreationDate:   Fri Feb  8 15:44:47 2013\n| ModDate:        Fri Feb  8 15:44:47 2013\n| Tagged:         no\n| Pages:          1\n| Encrypted:      no\n| Page size:      595 x 842 pts (A4)\n| File size:      36989 bytes\n| Optimized:      no\n| PDF version:    1.4\n| > rm score_table.pdf\n| > git checkout  score_table.pdf  \n| > git status\n| # On branch master\n| # Changes not staged for commit:\n| #   (use \"git add <file>...\" to update what will be committed)\n| #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n| #\n| #       modified:   score_table.pdf\n| #\n| # Untracked files:\n| #   (use \"git add <file>...\" to include in what will be committed)\n| #\n| #       .gitattributes\n| no changes added to commit (use \"git add\" and/or \"git commit -a\")\n| > pdfinfo score_table.pdf \n| Title:          (score_table)\n| Author:         (andreas)\n| Creator:        GPL Ghostscript 905 (ps2write)\n| Producer:       GPL Ghostscript 9.05\n| CreationDate:   Mon Jan  1 07:26:19 1979\n| ModDate:        Mon Jan  1 07:26:19 1979\n| Tagged:         no\n| Pages:          1\n| Encrypted:      no\n| Page size:      595 x 842 pts (A4)\n| File size:      37126 bytes\n| Optimized:      no\n| PDF version:    1.4\n| > git add score_table.pdf\n| > git status\n| # On branch master\n| # Changes to be committed:\n| #   (use \"git reset HEAD <file>...\" to unstage)\n| #\n| #       modified:   score_table.pdf\n| #\n| # Untracked files:\n| #   (use \"git add <file>...\" to include in what will be committed)\n| #\n| #       .gitattributes\n| > git diff score_table.pdf\n| > \n`----\n\nRegards,\nAndreas\n"},{"id":"217819","messageId":"5197AD3A.5050500@kdbg.org","threadId":"33817","inReplyTo":"87ppwohgyd.fsf@med.uni-goettingen.de","subject":"Re: make git ignore the timestamp embedded in PDFs","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2013-05-18T16:32:58Z","receivedAt":"2013-05-18T16:32:58Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 18.05.2013 09:42, schrieb Andreas Leha:\n>> Am 14.05.2013 15:17, schrieb Andreas Leha:\n>>> Hi all,\n>>>\n>>> how can I make git ignore the time stamp(s) in a PDF.  Two PDFs that\n>>> differ only in these time stamps should be considered identical.\n>>> ...\n>>> What I tried is a filter:\n>>> ,----[ ~/.gitconfig ]\n>>> | [filter \"pdfresetdate\"]\n>>> |         clean = pdfresetdate\n>>> `----\n>>>\n>>> This 'works' as far as the committed pdf indeed has the date reset to my\n>>> default value.\n>>>\n>>> However, when I re-checkout the files, they are marked modified by git.\n>>\n>> I'm using cleaned files every now and then, but not on Linux. I have\n>> never observed this behavior recently.\n>>\n>> If you 'git add' the file, does it keep its modified state? Does 'git\n> \n> yes.\n> \n>> diff' tell a difference?\n> \n> no.\n\nI do not believe you. I'm sure that \"Binary files differ\" was reported.\nThe reason is that your pdfresetdate script is not idempotent. Look:\n\n$ pdfresetdate < x.pdf > y.pdf\n$ pdfresetdate < y.pdf > z.pdf\n$ md5sum x.pdf y.pdf z.pdf\nc46a7097574a035e89d1a46d93c83528  x.pdf\n8e6d942b4cc7d8a4dfe6898867573617  y.pdf\ne6333bc0f8ab9781d3e1d811a392d516  z.pdf\n\nA file that was already cleaned by the clean filter must not be\nmodified, i.e., the y.pdf and z.pdf should be identical. But they are not.\n\nFix your clean filter.\n\n-- Hannes\n"},{"id":"217820","messageId":"87ip2ggnx9.fsf@med.uni-goettingen.de","threadId":"33817","inReplyTo":"5197AD3A.5050500@kdbg.org","subject":"Re: make git ignore the timestamp embedded in PDFs","fromName":"Andreas Leha","fromEmail":"andreas.leha@med.uni-goettingen.de","sentAt":"2013-05-18T18:09:38Z","receivedAt":"2013-05-18T18:09:38Z","isPatch":false,"sender":{"key":"andreas.leha@med.uni-goettingen.de","avatar":null},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> Am 18.05.2013 09:42, schrieb Andreas Leha:\n>>> Am 14.05.2013 15:17, schrieb Andreas Leha:\n>>>> Hi all,\n>>>>\n>>>> how can I make git ignore the time stamp(s) in a PDF.  Two PDFs that\n>>>> differ only in these time stamps should be considered identical.\n>>>> ...\n>>>> What I tried is a filter:\n>>>> ,----[ ~/.gitconfig ]\n>>>> | [filter \"pdfresetdate\"]\n>>>> |         clean = pdfresetdate\n>>>> `----\n>>>>\n>>>> This 'works' as far as the committed pdf indeed has the date reset to my\n>>>> default value.\n>>>>\n>>>> However, when I re-checkout the files, they are marked modified by git.\n>>>\n>>> I'm using cleaned files every now and then, but not on Linux. I have\n>>> never observed this behavior recently.\n>>>\n>>> If you 'git add' the file, does it keep its modified state? Does 'git\n>> \n>> yes.\n>> \n>>> diff' tell a difference?\n>> \n>> no.\n>\n> I do not believe you. I'm sure that \"Binary files differ\" was\n> reported.\n\nYou are correct, of course.  I had forgotten that I also had enabled a\nspecial diff for pdf files, that reports the difference in the pdfinfo\noutput.\n\n> The reason is that your pdfresetdate script is not idempotent. Look:\n>\n> $ pdfresetdate < x.pdf > y.pdf\n> $ pdfresetdate < y.pdf > z.pdf\n> $ md5sum x.pdf y.pdf z.pdf\n> c46a7097574a035e89d1a46d93c83528  x.pdf\n> 8e6d942b4cc7d8a4dfe6898867573617  y.pdf\n> e6333bc0f8ab9781d3e1d811a392d516  z.pdf\n>\n\nThanks for that.  I had not noticed due to the non-binary diff I had\nenabled.\n\n> A file that was already cleaned by the clean filter must not be\n> modified, i.e., the y.pdf and z.pdf should be identical. But they are not.\n>\n> Fix your clean filter.\n\nI will (try to) do.  Anyway, git seems unresponsible for my issue.\n\n\nThanks for that clear analysis!\n\nRegards,\nAndreas\n"}]}