/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { return "AbbreviatedObjectId[" + name() + "]"; //$NON-NLS-1$ } }
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 NoteParser(AbbreviatedObjectId prefix, ObjectReader r, ObjectId t) throws IncorrectObjectTypeException, IOException { super(encodeASCII(prefix.name()), r, t); prefixLen = prefix.length(); // Our path buffer has a '/' that we don't want after the prefix. // Drop it by shifting the path down one position. pathPadding = 0 < prefixLen ? 1 : 0; if (0 < pathPadding) System.arraycopy(path, 0, path, pathPadding, prefixLen); }
/** {@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; }
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$ }
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; }
/** * Creates a new simple push wizard which can be used to push out a certain * object. * * @param repo * the repository the object belongs to * @param objectId * the object that should be pushed. * @param title * the wizard title * @throws URISyntaxException */ public SimplePushRefWizard(Repository repo, ObjectId objectId, String title) throws URISyntaxException { this(repo, objectId, AbbreviatedObjectId.fromObjectId(objectId).name(), title); }
String fanOut = id.name().substring(0, 2); String[] entries = new File(getDirectory(), fanOut).list(); if (entries != null) { try { ObjectId entId = ObjectId.fromString(fanOut + e); if (id.prefixCompare(entId) == 0) matches.add(entId); } catch (IllegalArgumentException notId) {
if (ent.getOldId() != null && !ent.getOldId().equals(ent.getNewId())) { formatIndexLine(o, ent);
if (!id.isComplete()) { Collection<ObjectId> ids = reader.resolve(id); if (ids.size() == 1) { id = AbbreviatedObjectId.fromObjectId(ids.iterator().next()); switch (side) { case OLD: tooBig.setObjectId(id.toObjectId()); throw tooBig;
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); }
entry.oldId = AbbreviatedObjectId.fromObjectId(idBuf); entry.newId = AbbreviatedObjectId.fromObjectId(idBuf); r.add(entry); } else if (!entry.oldId.equals(entry.newId)) { entry.changeType = ChangeType.MODIFY; if (RenameDetector.sameType(entry.oldMode, entry.newMode))
@Override public boolean include(final RevCommit commit, final Collection<DiffEntry> diffs) { final DuplicateContainer dupes = new DuplicateContainer(commit); for (DiffEntry diff : diffs) { if (!isFileDiff(diff)) continue; switch (diff.getChangeType()) { case DELETE: continue; case COPY: case MODIFY: case RENAME: if (diff.getOldMode() != diff.getNewMode() && diff.getNewId().equals(diff.getOldId())) continue; default: dupes.include(diff.getNewId().toObjectId(), diff.getNewPath()); break; } } if (dupes.validate()) duplicates.put(commit, dupes); return true; }
static DiffEntry add(String path, AnyObjectId id) { DiffEntry e = new DiffEntry(); e.oldId = A_ZERO; e.oldMode = FileMode.MISSING; e.oldPath = DEV_NULL; e.newId = AbbreviatedObjectId.fromObjectId(id); e.newMode = FileMode.REGULAR_FILE; e.newPath = path; e.changeType = ChangeType.ADD; return e; }
/** * Whether this ObjectId is actually a complete id. * * @return true if this ObjectId is actually a complete id. */ public boolean isComplete() { return length() == Constants.OBJECT_ID_STRING_LENGTH; }
throws IOException { if (len == Constants.OBJECT_ID_STRING_LENGTH) return AbbreviatedObjectId.fromObjectId(objectId); List<ObjectId> n = new ArrayList<>(8); for (ObjectId candidate : matches) { if (abbrev.prefixCompare(candidate) == 0) n.add(candidate);
private RawText open(DiffEntry.Side side, DiffEntry entry) throws IOException, BinaryBlobException { if (entry.getMode(side) == FileMode.MISSING) return RawText.EMPTY_TEXT; if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB) return RawText.EMPTY_TEXT; 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.size() == 0) throw new MissingObjectException(id, Constants.OBJ_BLOB); else throw new AmbiguousObjectException(id, ids); } ObjectLoader ldr = LfsFactory.getInstance().applySmudgeFilter(repository, source.open(side, entry), entry.getDiffAttribute()); return RawText.load(ldr, binaryFileThreshold); }
if (!Objects.equal(entry.getOldPath(), entry.getNewPath()) || !Objects.equal(entry.getOldMode(), entry.getNewMode()) || entry.getOldId()==null || !entry.getOldId().isComplete() || entry.getNewId()== null || !entry.getNewId().isComplete() || !entry.getOldId().equals(entry.getNewId())) { diffs.add(entry);
/** * A complete ObjectId; null if {@link #isComplete()} is false * * @return a complete ObjectId; null if {@link #isComplete()} is false */ public ObjectId toObjectId() { return isComplete() ? new ObjectId(w1, w2, w3, w4, w5) : null; }
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$ }