Skip to contentSkip to conversation

Paper bag fix IndexPack thin pack completion support

PATCH New Shawn O. Pearce 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Paper bag fix IndexPack thin pack completion support

We must write the whole object at the end of the file, not in the middle of the file on top of some delta (or other) whole object. Writing in the middle of the file causes subtle corruption as we cannot unpack a delta.

---

This is a serious data corruption in IndexPack. It was introduced by me in "Compute packed object entry CRC32 data during IndexPack", which is presently in pu as 4b8e1c0c. It would be best if we squash this into the commit.

 .../src/org/spearce/jgit/transport/IndexPack.java  |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java +1 -1
index b35cec3..24a0577 100644
@@ -407,10 +407,10 @@ public class IndexPack {
 			final PackedObjectInfo oe;
 
 			crc.reset();
+			packOut.seek(end);
 			writeWhole(def, typeCode, data);
 			oe = new PackedObjectInfo(end, (int) crc.getValue(), baseId);
 			entries[entryCount++] = oe;
-			packOut.seek(end);
 			end = packOut.getFilePointer();
 
 			resolveChildDeltas(oe.getOffset(), typeCode, data, oe);
Signature · 4 lines
1.5.6.74.g8a5e

-- 
Shawn.