ObjectId.fromString("c59759f143fb1fe21c197981df75a7ee00290799"),
ObjectId.fromString("aabf2ffaec9b497f0950352b3e582d73035c2035"),
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
- ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"),
- ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") };
+ ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
+ ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
try (final RevWalk parser = new RevWalk(db)) {
final RevObject forcedOrderRevs[] = new RevObject[forcedOrder.length];
for (int i = 0; i < forcedOrder.length; i++)
*/
@Test
public void testWritePack2SizeDeltasVsNoDeltas() throws Exception {
+ config.setReuseDeltas(false);
+ config.setDeltaCompress(false);
testWritePack2();
final long sizePack2NoDeltas = os.size();
tearDown();
ObjectId.fromString("aabf2ffaec9b497f0950352b3e582d73035c2035"),
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
ObjectId.fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904"),
- ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"),
- ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") };
+ ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3"),
+ ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
assertEquals(expectedOrder.length, writer.getObjectCount());
verifyObjectsOrder(expectedOrder);
ObjectId.fromString("c59759f143fb1fe21c197981df75a7ee00290799"),
ObjectId.fromString("aabf2ffaec9b497f0950352b3e582d73035c2035"),
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
- ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"),
- ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") };
- if (deltaReuse) {
- // objects order influenced (swapped) by delta-base first rule
- ObjectId temp = expectedOrder[4];
- expectedOrder[4] = expectedOrder[5];
- expectedOrder[5] = temp;
+ ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
+ ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
+ if (!config.isReuseDeltas() && !config.isDeltaCompress()) {
+ // If no deltas are in the file the final two entries swap places.
+ swap(expectedOrder, 4, 5);
}
assertEquals(expectedOrder.length, writer.getObjectCount());
verifyObjectsOrder(expectedOrder);
.computeName().name());
}
+ private static void swap(ObjectId[] arr, int a, int b) {
+ ObjectId tmp = arr[a];
+ arr[a] = arr[b];
+ arr[b] = tmp;
+ }
+
private void writeVerifyPack4(final boolean thin) throws IOException {
final HashSet<ObjectId> interestings = new HashSet<ObjectId>();
interestings.add(ObjectId
clear(n);
}
res.set(next);
+ clearWindowOnTypeSwitch();
if (res.object.isEdge() || res.object.doNotAttemptDelta()) {
// We don't actually want to make a delta for
return DeltaIndex.estimateIndexSize(len) - len;
}
+ private void clearWindowOnTypeSwitch() {
+ DeltaWindowEntry p = res.prev;
+ if (!p.empty() && res.type() != p.type()) {
+ for (; p != res; p = p.prev) {
+ clear(p);
+ }
+ }
+ }
+
private void clear(DeltaWindowEntry ent) {
if (ent.index != null)
loaded -= ent.index.getIndexSize();
private boolean delta(final DeltaWindowEntry src)
throws IOException {
- // Objects must use only the same type as their delta base.
- if (src.type() != res.type()) {
- keepInWindow();
- return NEXT_RES;
- }
-
// If the sizes are radically different, this is a bad pairing.
if (res.size() < src.size() >>> 4)
return NEXT_SRC;