jgit/org.eclipse.jgit
Shawn O. Pearce 06ee913c8d IndexPack: Correct thin pack fix using less than 20 bytes
If we need to append less than 20 bytes in order to fix a thin pack
and make it complete, we need to set the length of our file back to
the actual number of bytes used because the original SHA-1 footer was
not completely overwritten.  That extra data will confuse the header
and footer fixup logic when it tries to read to the end of the file.

This isn't a very common case to occur, which is why we've never
seen it before.  Getting a delta that requires a whole object which
uses less than 20 bytes in pack representation is really hard.
Generally a delta generator won't make these, because the delta
would be bigger than simply deflating the whole object.  I only
managed to do this with a hand-crafted pack file where a 1 byte
delta was pointed to a 1 byte whole object.

Normally we try really hard to avoid truncating, because its
typically not safe across network filesystems.  But the odds of
this occurring are very low.  This truncation is done on a file
we have open for writing, will append more content onto, and is
a temporary file that we won't move into position for others to
see until we've validated its SHA-1 is sane.  I don't think the
truncate on NFS issue is something we need to worry about here.

Change-Id: I102b9637dfd048dc833c050890d142f43c1e75ae
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-04-16 15:56:23 -07:00
..
.settings Adding PDE API Tools nature to JGit 2010-01-16 10:00:30 -06:00
META-INF JGit plugin not compatible with Eclipse 3.4 2010-04-05 12:25:06 +02:00
findBugs Initial JGit contribution to eclipse.org 2009-09-29 16:47:03 -07:00
src/org/eclipse/jgit IndexPack: Correct thin pack fix using less than 20 bytes 2010-04-16 15:56:23 -07:00
.classpath Partial revert "Switch build to Apache Felix maven-bundle-plugin" 2010-01-10 15:59:03 +01:00
.fbprefs Initial JGit contribution to eclipse.org 2009-09-29 16:47:03 -07:00
.gitignore Finish removing Apache Felix maven-bundle-plugin 2010-01-12 11:46:55 -08:00
.project Adding PDE API Tools nature to JGit 2010-01-16 10:00:30 -06:00
about.html Adding some Eclipse-related legal files to JGit 2010-02-03 15:18:06 -06:00
build.properties Adding some Eclipse-related legal files to JGit 2010-02-03 15:18:06 -06:00
plugin.properties Correct bundle, provider names to be consistent 2010-01-23 11:42:15 -08:00
pom.xml Qualify builds as 0.8.0 2010-03-20 19:06:58 -07:00