List of usage examples for org.eclipse.jgit.errors AmbiguousObjectException AmbiguousObjectException
public AmbiguousObjectException(final AbbreviatedObjectId id, final Collection<ObjectId> candidates)
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 ww w.j av a 2 s . co 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:com.madgag.agit.diff.LineContextDiffer.java
License:Open Source License
private byte[] open(ObjectReader reader, FileMode mode, AbbreviatedObjectId id) throws IOException { if (mode == FileMode.MISSING) return new byte[] {}; if (mode.getObjectType() != Constants.OBJ_BLOB) return new byte[] {}; if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); else if (ids.size() == 0) throw new MissingObjectException(id, Constants.OBJ_BLOB); else/* w w w. java2 s . c o m*/ throw new AmbiguousObjectException(id, ids); } ObjectLoader ldr = reader.open(id.toObjectId()); return ldr.getCachedBytes(bigFileThreshold); }
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; }// w w w. j ava2 s. co m 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()); }