List of usage examples for org.eclipse.jgit.diff DiffEntry getId
public AbbreviatedObjectId getId(Side side)
From source file:MyDiffFormatter.java
License:Eclipse Distribution License
private byte[] open(DiffEntry.Side side, DiffEntry entry) throws IOException { if (entry.getMode(side) == FileMode.MISSING) return EMPTY; if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB) return EMPTY; AbbreviatedObjectId id = entry.getId(side); if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) { throw new IllegalStateException(); // id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); // switch (side) { // case OLD: // entry.oldId = id; // break; // case NEW: // entry.newId = id; // break; // } } else if (ids.size() == 0) throw new MissingObjectException(id, Constants.OBJ_BLOB); else//from www . j a v a2 s . c o m throw new AmbiguousObjectException(id, ids); } try { ObjectLoader ldr = source.open(side, entry); int binaryFileThreshold = DEFAULT_BINARY_FILE_THRESHOLD; return ldr.getBytes(binaryFileThreshold); } catch (LargeObjectException.ExceedsLimit overLimit) { return BINARY; } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) { return BINARY; } catch (LargeObjectException.OutOfMemory tooBig) { return BINARY; } catch (LargeObjectException tooBig) { tooBig.setObjectId(id.toObjectId()); throw tooBig; } }
From source file:jbenchmarker.trace.git.GitExtraction.java
License:Open Source License
byte[] open(DiffEntry.Side side, DiffEntry entry) throws IOException { if (entry.getMode(side) == FileMode.MISSING) { return EMPTY; }// ww w . ja va 2 s . com if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB) { return EMPTY; } AbbreviatedObjectId id = entry.getId(side); if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) { // id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); // switch (side) { // case OLD: // entry.oldId = id; // break; // case NEW: // entry.newId = id; // break; // } } else if (ids.isEmpty()) { throw new MissingObjectException(id, Constants.OBJ_BLOB); } else { throw new AmbiguousObjectException(id, ids); } } ObjectLoader ldr = pairSource.open(side, entry); return getBytes(ldr, id.toObjectId()); }