use of org.eclipse.jgit.lib.ObjectStream in project gerrit by GerritCodeReview.
the class ReviewNoteMerger method merge.
@Override
public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter) throws IOException {
if (ours == null) {
return theirs;
}
if (theirs == null) {
return ours;
}
if (ours.getData().equals(theirs.getData())) {
return ours;
}
ObjectLoader lo = reader.open(ours.getData());
byte[] sep = new byte[] { '\n' };
ObjectLoader lt = reader.open(theirs.getData());
try (ObjectStream os = lo.openStream();
ByteArrayInputStream b = new ByteArrayInputStream(sep);
ObjectStream ts = lt.openStream();
UnionInputStream union = new UnionInputStream(os, b, ts)) {
ObjectId noteData = inserter.insert(Constants.OBJ_BLOB, lo.getSize() + sep.length + lt.getSize(), union);
return new Note(ours, noteData);
}
}
Aggregations