|
|
@ -75,6 +75,7 @@ import org.eclipse.jgit.lib.NullProgressMonitor; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectIdSet; |
|
|
|
import org.eclipse.jgit.lib.ObjectIdSet; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.Sets; |
|
|
|
import org.eclipse.jgit.revwalk.RevBlob; |
|
|
|
import org.eclipse.jgit.revwalk.RevBlob; |
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
import org.eclipse.jgit.revwalk.RevCommit; |
|
|
|
import org.eclipse.jgit.revwalk.RevObject; |
|
|
|
import org.eclipse.jgit.revwalk.RevObject; |
|
|
@ -92,6 +93,9 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
private static final List<RevObject> EMPTY_LIST_REVS = Collections |
|
|
|
private static final List<RevObject> EMPTY_LIST_REVS = Collections |
|
|
|
.<RevObject> emptyList(); |
|
|
|
.<RevObject> emptyList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Set<ObjectIdSet> EMPTY_ID_SET = Collections |
|
|
|
|
|
|
|
.<ObjectIdSet> emptySet(); |
|
|
|
|
|
|
|
|
|
|
|
private PackConfig config; |
|
|
|
private PackConfig config; |
|
|
|
|
|
|
|
|
|
|
|
private PackWriter writer; |
|
|
|
private PackWriter writer; |
|
|
@ -202,8 +206,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
createVerifyOpenPack(NONE, Collections.singleton(nonExisting), |
|
|
|
createVerifyOpenPack(NONE, haves(nonExisting), false, false); |
|
|
|
false, false); |
|
|
|
|
|
|
|
fail("Should have thrown MissingObjectException"); |
|
|
|
fail("Should have thrown MissingObjectException"); |
|
|
|
} catch (MissingObjectException x) { |
|
|
|
} catch (MissingObjectException x) { |
|
|
|
// expected
|
|
|
|
// expected
|
|
|
@ -219,8 +222,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
public void testIgnoreNonExistingObjects() throws IOException { |
|
|
|
public void testIgnoreNonExistingObjects() throws IOException { |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
createVerifyOpenPack(NONE, Collections.singleton(nonExisting), |
|
|
|
createVerifyOpenPack(NONE, haves(nonExisting), false, true); |
|
|
|
false, true); |
|
|
|
|
|
|
|
// shouldn't throw anything
|
|
|
|
// shouldn't throw anything
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -238,8 +240,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
final ObjectId nonExisting = ObjectId |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
.fromString("0000000000000000000000000000000000000001"); |
|
|
|
new GC(db).gc(); |
|
|
|
new GC(db).gc(); |
|
|
|
createVerifyOpenPack(NONE, Collections.singleton(nonExisting), false, |
|
|
|
createVerifyOpenPack(NONE, haves(nonExisting), false, true, true); |
|
|
|
true, true); |
|
|
|
|
|
|
|
// shouldn't throw anything
|
|
|
|
// shouldn't throw anything
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -516,8 +517,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
RevBlob contentA = testRepo.blob("A"); |
|
|
|
RevBlob contentA = testRepo.blob("A"); |
|
|
|
RevCommit c1 = bb.commit().add("f", contentA).create(); |
|
|
|
RevCommit c1 = bb.commit().add("f", contentA).create(); |
|
|
|
testRepo.getRevWalk().parseHeaders(c1); |
|
|
|
testRepo.getRevWalk().parseHeaders(c1); |
|
|
|
PackIndex pf1 = writePack(repo, Collections.singleton(c1), |
|
|
|
PackIndex pf1 = writePack(repo, wants(c1), EMPTY_ID_SET); |
|
|
|
Collections.<ObjectIdSet> emptySet()); |
|
|
|
|
|
|
|
assertContent( |
|
|
|
assertContent( |
|
|
|
pf1, |
|
|
|
pf1, |
|
|
|
Arrays.asList(c1.getId(), c1.getTree().getId(), |
|
|
|
Arrays.asList(c1.getId(), c1.getTree().getId(), |
|
|
@ -525,8 +525,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
RevBlob contentB = testRepo.blob("B"); |
|
|
|
RevBlob contentB = testRepo.blob("B"); |
|
|
|
RevCommit c2 = bb.commit().add("f", contentB).create(); |
|
|
|
RevCommit c2 = bb.commit().add("f", contentB).create(); |
|
|
|
testRepo.getRevWalk().parseHeaders(c2); |
|
|
|
testRepo.getRevWalk().parseHeaders(c2); |
|
|
|
PackIndex pf2 = writePack(repo, Collections.singleton(c2), |
|
|
|
PackIndex pf2 = writePack(repo, wants(c2), Sets.of((ObjectIdSet) pf1)); |
|
|
|
Collections.<ObjectIdSet> singleton(pf1)); |
|
|
|
|
|
|
|
assertContent( |
|
|
|
assertContent( |
|
|
|
pf2, |
|
|
|
pf2, |
|
|
|
Arrays.asList(c2.getId(), c2.getTree().getId(), |
|
|
|
Arrays.asList(c2.getId(), c2.getTree().getId(), |
|
|
@ -730,4 +729,12 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { |
|
|
|
assertEquals(objectsOrder[i++].toObjectId(), me.toObjectId()); |
|
|
|
assertEquals(objectsOrder[i++].toObjectId(), me.toObjectId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<ObjectId> haves(ObjectId... objects) { |
|
|
|
|
|
|
|
return Sets.of(objects); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Set<ObjectId> wants(ObjectId... objects) { |
|
|
|
|
|
|
|
return Sets.of(objects); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|