Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (revision 1781385) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (working copy) @@ -2475,6 +2475,14 @@ RevisionVector toRev) { long minTimestamp = Utils.getMinTimestampForDiff( fromRev, toRev, getMinExternalRevisions()); + for (RevisionVector r : new RevisionVector[]{fromRev, toRev}) { + if (r.isBranch()) { + Branch b = branches.getBranch(r); + if (b != null) { + minTimestamp = Math.min(b.getBase().getRevision(clusterId).getTimestamp(), minTimestamp); + } + } + } long minValue = NodeDocument.getModifiedInSecs(minTimestamp); String fromKey = Utils.getKeyLowerLimit(path); String toKey = Utils.getKeyUpperLimit(path); Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranchesTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranchesTest.java (revision 1781386) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreBranchesTest.java (working copy) @@ -41,13 +41,11 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@Ignore("OAK-5557") public class DocumentNodeStoreBranchesTest { static final Logger LOG = LoggerFactory.getLogger(DocumentNodeStoreBranchesTest.class);