libgit2/libgit2 — pull request #1860 by carlosmn (2013-09-18 00:29:27+00:00)
Title: indexer: check the packfile trailer

It has been bothering me since I wrote the original version that we don't check that the trailer is correct. Simply keeping back the last 20B out of the file on-disc causes problems, as the packfile layer expects the trailer to be there and won't let us read all of the objects, which is why (I now realise) my earlier attempt failed when the math seemed to work out.

So what we do instead is simply to write out everything but leave out the last 20B from what we hash, compare with what's on-disc and complain if it's not correct.