Let ObjectWalk.markUninteresting also mark the root tree as
uninteresting Using the ObjectWalk and marking a commit as uninteresting didn't mark its root tree as uninteresting. This caused the "missing tree ..." error in Gerrit under special circumstances. For example, if the patch-set 2 changes only the commit message then the patch-set 1 and patch-set 2 share the same root-tree: ps1 -> o o <- ps2 \ / o root-tree The transported pack will contain the ps2 commit but not the root-tree object. When using the BaseReceivePack.setCheckReferencedObjectsAreReachable JGit will check the reachability of all referenced objects not provided in the transported pack. Since the ps1 was advertised it will properly be marked as uninteresting. However, the root-tree was reachable because the ObjectWalk.markUninteresting missed to mark it as uninteresting. JGit was then rejecting the pack with the "missing tree ..." exception. Gerrit-issue: https://code.google.com/p/gerrit/issues/detail?id=1582 Change-Id: Iff2de8810f14ca304e6655fc8debeb8f3e20712b Signed-off-by: Saša Živkov <sasa.zivkov@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
684a2a058a
commit
c4797fe986
|
@ -214,6 +214,21 @@ public void testCull() throws Exception {
|
|||
assertNull(objw.nextObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkUninterestingPropagation() throws Exception {
|
||||
final RevBlob f = blob("1");
|
||||
final RevTree t = tree(file("f", f));
|
||||
final RevCommit c1 = commit(t);
|
||||
final RevCommit c2 = commit(t);
|
||||
|
||||
markUninteresting(c1);
|
||||
markStart(c2);
|
||||
|
||||
assertSame(c2, objw.next());
|
||||
assertNull(objw.next());
|
||||
assertNull(objw.nextObject());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyTreeCorruption() throws Exception {
|
||||
ObjectId bId = ObjectId
|
||||
|
|
|
@ -232,7 +232,7 @@ public void markUninteresting(RevObject o) throws MissingObjectException,
|
|||
}
|
||||
|
||||
if (o instanceof RevCommit)
|
||||
super.markUninteresting((RevCommit) o);
|
||||
markUninteresting((RevCommit) o);
|
||||
else if (o instanceof RevTree)
|
||||
markTreeUninteresting((RevTree) o);
|
||||
else
|
||||
|
@ -242,6 +242,13 @@ else if (o instanceof RevTree)
|
|||
addObject(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markUninteresting(RevCommit c) throws MissingObjectException,
|
||||
IncorrectObjectTypeException, IOException {
|
||||
super.markUninteresting(c);
|
||||
markTreeUninteresting(c.getTree());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sort(RevSort s) {
|
||||
super.sort(s);
|
||||
|
|
Loading…
Reference in New Issue