public static ArrayMemory valueOf(DiffEntry value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("oldId").assign(value.getOldId() == null ? Memory.NULL : valueOf(value.getOldId().toObjectId())); memory.refOfIndex("oldPath").assign(value.getOldPath()); memory.refOfIndex("oldMode").assign(value.getOldMode() == null ? Memory.NULL : StringMemory.valueOf(value.getOldMode().toString())); memory.refOfIndex("newId").assign(value.getNewId() == null ? Memory.NULL : valueOf(value.getNewId().toObjectId())); memory.refOfIndex("newPath").assign(value.getNewPath()); memory.refOfIndex("newMode").assign(value.getNewMode() == null ? Memory.NULL : StringMemory.valueOf(value.getNewMode().toString())); memory.refOfIndex("score").assign(value.getScore()); memory.refOfIndex("changeType").assign(value.getChangeType().name()); return memory; }
/** {@inheritDoc} */ @Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<>(4); db.resolve(matches, id); return matches; }
/** * Determine the size of the object. * * @param side * which side of the entry to read (OLD or NEW). * @param ent * the entry to examine. * @return the size in bytes. * @throws IOException * the file cannot be accessed. */ public long size(DiffEntry.Side side, DiffEntry ent) throws IOException { switch (side) { case OLD: return oldSource.size(ent.oldPath, ent.oldId.toObjectId()); case NEW: return newSource.size(ent.newPath, ent.newId.toObjectId()); default: throw new IllegalArgumentException(); } }
/** * Open the object. * * @param side * which side of the entry to read (OLD or NEW). * @param ent * the entry to examine. * @return a loader that can supply the content of the file. The loader * must be used before another loader can be obtained from this * same source. * @throws IOException * the file cannot be accessed. */ public ObjectLoader open(DiffEntry.Side side, DiffEntry ent) throws IOException { switch (side) { case OLD: return oldSource.open(ent.oldPath, ent.oldId.toObjectId()); case NEW: return newSource.open(ent.newPath, ent.newId.toObjectId()); default: throw new IllegalArgumentException(); } } }
private String format(AbbreviatedObjectId id) { if (id.isComplete() && reader != null) { try { id = reader.abbreviate(id.toObjectId(), abbreviationLength); } catch (IOException cannotAbbreviate) { // Ignore this. We'll report the full identity. } } return id.name(); }
/** {@inheritDoc} */ @Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, matches); if (matches.size() < MAX_RESOLVE_MATCHES && packList.dirty()) { stats.scanPacks++; resolveImpl(db.scanPacks(packList), id, matches); } return matches; }
private static byte[] writeGitLinkText(AbbreviatedObjectId id) { if (ObjectId.zeroId().equals(id.toObjectId())) { return EMPTY; } return encodeASCII("Subproject commit " + id.name() //$NON-NLS-1$ + "\n"); //$NON-NLS-1$ }
private ObjectId extractObjectId(AbbreviatedObjectId objectId) { if (objectId != null) return objectId.toObjectId(); else return zeroId(); }
@SneakyThrows private String getService(final GitUtil git, final AbbreviatedObjectId id) { return git.readObject(id.toObjectId()); }
@Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<ObjectId>(4); db.resolve(matches, id); return matches; }
/** {@inheritDoc} */ @Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); HashSet<ObjectId> matches = new HashSet<>(4); db.resolve(matches, id); return matches; }
/** * Get blob object ids * * @return non-null but possibly empty array of object ids */ public ObjectId[] getBlobs() { List<ObjectId> objectIds = new ArrayList<ObjectId>(); if (diffEntry.getOldId() != null) objectIds.add(diffEntry.getOldId().toObjectId()); if (diffEntry.getNewId() != null) objectIds.add(diffEntry.getNewId().toObjectId()); return objectIds.toArray(new ObjectId[]{}); }
private boolean processOne(Candidate n) throws IOException { RevCommit parent = n.getParent(0); if (parent == null) return split(n.getNextCandidate(0), n); revPool.parseHeaders(parent); if (find(parent, n.sourcePath)) { if (idBuf.equals(n.sourceBlob)) return blameEntireRegionOnParent(n, parent); return splitBlameWithParent(n, parent); } if (n.sourceCommit == null) return result(n); DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath); if (r == null) return result(n); if (0 == r.getOldId().prefixCompare(n.sourceBlob)) { // A 100% rename without any content change can also // skip directly to the parent. n.sourceCommit = parent; n.sourcePath = PathFilter.create(r.getOldPath()); push(n); return false; } Candidate next = n.create(getRepository(), parent, PathFilter.create(r.getOldPath())); next.sourceBlob = r.getOldId().toObjectId(); next.renameScore = r.getScore(); next.loadText(reader); return split(next, n); }
if (ids == null) ids = new ObjectId[pCnt]; ids[pCnt] = r.getOldId().toObjectId(); } else if (0 == r.getOldId().prefixCompare(n.sourceBlob)) { PathFilter.create(renames[pIdx].getOldPath())); p.renameScore = renames[pIdx].getScore(); p.sourceBlob = renames[pIdx].getOldId().toObjectId(); } else if (ids != null && ids[pIdx] != null) { p = n.create(getRepository(), parent, n.sourcePath);
private String format(AbbreviatedObjectId id) { if (id.isComplete() && reader != null) { try { id = reader.abbreviate(id.toObjectId(), abbreviationLength); } catch (IOException cannotAbbreviate) { // Ignore this. We'll report the full identity. } } return id.name(); }
private String format(AbbreviatedObjectId id) { if (id.isComplete() && reader != null) { try { id = reader.abbreviate(id.toObjectId(), abbreviationLength); } catch (IOException cannotAbbreviate) { // Ignore this. We'll report the full identity. } } return id.name(); }
@Override public Collection<ObjectId> resolve(AbbreviatedObjectId id) throws IOException { if (id.isComplete()) return Collections.singleton(id.toObjectId()); boolean noGarbage = avoidUnreachable; HashSet<ObjectId> matches = new HashSet<ObjectId>(4); PackList packList = db.getPackList(); resolveImpl(packList, id, noGarbage, matches); if (matches.size() < MAX_RESOLVE_MATCHES && packList.dirty()) { resolveImpl(db.scanPacks(packList), id, noGarbage, matches); } return matches; }
private String getSourceCode(Repository repo, DiffEntry diff) throws IOException { if(!collectConfig.isCollectingSourceCode()) return ""; try { ObjectReader reader = repo.newObjectReader(); byte[] bytes = reader.open(diff.getNewId().toObjectId()).getBytes(); return new String(bytes, "utf-8"); } catch (Throwable e) { return ""; } }
private static byte[] writeGitLinkText(AbbreviatedObjectId id) { if (ObjectId.zeroId().equals(id.toObjectId())) { return EMPTY; } return encodeASCII("Subproject commit " + id.name() //$NON-NLS-1$ + "\n"); //$NON-NLS-1$ }
private static byte[] writeGitLinkText(AbbreviatedObjectId id) { if (id.toObjectId().equals(ObjectId.zeroId())) { return EMPTY; } return encodeASCII("Subproject commit " + id.name() //$NON-NLS-1$ + "\n"); //$NON-NLS-1$ }