diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-09-25 17:29:35 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-09-25 19:01:42 -0400 |
commit | fa4f00b7ed248d420ba12c576f944e873a3b8095 (patch) | |
tree | 66cf119a1296933b2ca8d085e66804291bc28ac8 /org.eclipse.jgit.test/tst | |
parent | 6d00f0a09c67421d4ac9960c568f9c18ceb4a6a4 (diff) | |
download | jgit-fa4f00b7ed248d420ba12c576f944e873a3b8095.tar.gz jgit-fa4f00b7ed248d420ba12c576f944e873a3b8095.zip |
Fix PackWriterBitmapWalker handling non-existing uninteresting objects
When writing new packs it should be allowed to specify objects as "have"
(objects which should not be included in the pack) which do not exist in
the local repository.
This works with the traditional PackWriter, but when PackWriter was
working on a repository with bitmap indexes and used
PackWriterBitmapWalker then this feature was broken. Non-existing "have"
objects lead to MissingObjectExceptions. That broke push and Gerrit
replication. When the replication target had branches unknown to the
replication source then the source repository wanted to build pack files
where "have" included branch-tips which were unknown in the source
repository.
Bug: 427107
Change-Id: I6b6598a1ec49af68aa77ea6f1f06e827982ea4ac
Also-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java index aba48bc35f..873b2cda45 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java @@ -54,6 +54,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -225,6 +226,25 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { } /** + * Try to pass non-existing object as uninteresting, with ignoring setting. + * Use a repo with bitmap indexes because then PackWriter will use + * PackWriterBitmapWalker which had problems with this situation. + * + * @throws IOException + * @throws ParseException + */ + @Test + public void testIgnoreNonExistingObjectsWithBitmaps() throws IOException, + ParseException { + final ObjectId nonExisting = ObjectId + .fromString("0000000000000000000000000000000000000001"); + new GC(db).gc(); + createVerifyOpenPack(EMPTY_SET_OBJECT, + Collections.singleton(nonExisting), false, true, true); + // shouldn't throw anything + } + + /** * Create pack basing on only interesting objects, then precisely verify * content. No delta reuse here. * @@ -604,8 +624,17 @@ public class PackWriterTest extends SampleDataRepositoryTestCase { final Set<ObjectId> uninterestings, final boolean thin, final boolean ignoreMissingUninteresting) throws MissingObjectException, IOException { + createVerifyOpenPack(interestings, uninterestings, thin, + ignoreMissingUninteresting, false); + } + + private void createVerifyOpenPack(final Set<ObjectId> interestings, + final Set<ObjectId> uninterestings, final boolean thin, + final boolean ignoreMissingUninteresting, boolean useBitmaps) + throws MissingObjectException, IOException { NullProgressMonitor m = NullProgressMonitor.INSTANCE; writer = new PackWriter(config, db.newObjectReader()); + writer.setUseBitmaps(useBitmaps); writer.setThin(thin); writer.setIgnoreMissingUninteresting(ignoreMissingUninteresting); writer.preparePack(m, interestings, uninterestings); |