/** * Convert an ObjectId into a hex string representation. * * @param i * the id to convert. May be null. * @return the hex string conversion of this id's content. */ public static final String toString(ObjectId i) { return i != null ? i.name() : ZEROID_STR; }
/** * Construct a stage builder for a transaction. * * @param txnStageNamespace * namespace for transaction references to build * {@code "txnStageNamespace/txnId.n"} style names. * @param txnId * identifier used to name temporary staging refs. */ public StageBuilder(String txnStageNamespace, ObjectId txnId) { this.txnStage = txnStageNamespace; this.txnId = txnId.name(); }
/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { return "RemoteRefUpdate[remoteName=" + remoteName + ", " + status + ", " + (expectedOldObjectId != null ? expectedOldObjectId.name() : "(null)") + "..." + (newObjectId != null ? newObjectId.name() : "(null)") + (fastForward ? ", fastForward" : "") + ", srcRef=" + srcRef + (forceUpdate ? ", forceUpdate" : "") + ", message=" + (message != null ? "\"" + message + "\"" : "null") + "]"; } }
/** * Construct a CorruptObjectException for reporting a problem specified * object id * * @param id * a {@link org.eclipse.jgit.lib.ObjectId} * @param why * error message */ public CorruptObjectException(ObjectId id, String why) { super(MessageFormat.format(JGitText.get().objectIsCorrupt, id.name(), why)); }
private static String format(Map<ObjectId, String> missingCommits) { final StringBuilder r = new StringBuilder(); r.append(JGitText.get().missingPrerequisiteCommits); for (Map.Entry<ObjectId, String> e : missingCommits.entrySet()) { r.append("\n "); //$NON-NLS-1$ r.append(e.getKey().name()); if (e.getValue() != null) r.append(" ").append(e.getValue()); //$NON-NLS-1$ } return r.toString(); }
/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { return "Note[" + name() + " -> " + data.name() + "]"; } }
/** * Construct and IncorrectObjectTypeException for the specified object id. * * Provide the type to make it easier to track down the problem. * * @param id SHA-1 * @param type object type */ public IncorrectObjectTypeException(ObjectId id, String type) { super(MessageFormat.format(JGitText.get().objectIsNotA, id.name(), type)); }
private static String noteData(Note n) { if (n != null) return n.getData().name(); return ""; //$NON-NLS-1$ }
/** * Initialize with default message. * * @param id * object whose contents are a hash collision. */ public Sha1CollisionException(ObjectId id) { super(MessageFormat.format( JGitText.get().sha1CollisionDetected1, id.name())); } }
private void want(ObjectId id) { askFor.put(id, new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, id.name(), id)); }
private StringBuilder toStringBuilder() { StringBuilder sb = new StringBuilder() .append(VERSION).append(' ').append(version).append('\n') .append(PUSHER).append(' ').append(getPusher()) .append('\n'); if (pushee != null) { sb.append(PUSHEE).append(' ').append(pushee).append('\n'); } sb.append(NONCE).append(' ').append(nonce).append('\n') .append('\n'); for (ReceiveCommand cmd : commands) { sb.append(cmd.getOldId().name()) .append(' ').append(cmd.getNewId().name()) .append(' ').append(cmd.getRefName()).append('\n'); } return sb; }
/** * Construct a MissingObjectException for the specified object id. * Expected type is reported to simplify tracking down the problem. * * @param id SHA-1 * @param type object type */ public MissingObjectException(ObjectId id, String type) { super(MessageFormat.format(JGitText.get().missingObject, type, id.name())); missing = id.copy(); }
private static void append(StringBuilder s, Ref r, String nullName) { if (r == null) { s.append(nullName); } else if (r.isSymbolic()) { s.append(r.getTarget().getName()); } else { ObjectId id = r.getObjectId(); if (id != null) { s.append(id.name()); } } }
/** * Get the hex encoded name of the object, or 'unknown object' * * @return either the hex encoded name of the object, or 'unknown object' */ protected String getObjectName() { if (getObjectId() != null) return getObjectId().name(); return JGitText.get().unknownObject; }
private void queueWants(Collection<Ref> want) throws TransportException { final HashSet<ObjectId> inWorkQueue = new HashSet<>(); for (Ref r : want) { final ObjectId id = r.getObjectId(); if (id == null) { throw new NullPointerException(MessageFormat.format( JGitText.get().transportProvidedRefWithNoObjectId, r.getName())); } try { final RevObject obj = revWalk.parseAny(id); if (obj.has(COMPLETE)) continue; if (inWorkQueue.add(id)) { obj.add(IN_WORK_QUEUE); workQueue.add(obj); } } catch (MissingObjectException e) { if (inWorkQueue.add(id)) workQueue.add(id); } catch (IOException e) { throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e); } } }
private void fetch(Transport transport, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (FetchConnection conn = transport.openFetch()) { Map<String, Ref> remoteRefs = conn.getRefsMap(); req.setRefs(remoteRefs); List<Ref> want = new ArrayList<>(); for (String name : req.getWantRefs()) { Ref ref = remoteRefs.get(name); if (ref != null && ref.getObjectId() != null) { want.add(ref); } } for (ObjectId id : req.getWantObjects()) { want.add(new ObjectIdRef.Unpeeled(NETWORK, id.name(), id)); } conn.fetch(NullProgressMonitor.INSTANCE, want, Collections.<ObjectId> emptySet()); } }
private void markLocalRefsComplete(Set<ObjectId> have) throws TransportException { List<Ref> refs; try { refs = local.getRefDatabase().getRefs(); } catch (IOException e) { throw new TransportException(e.getMessage(), e); } for (Ref r : refs) { try { markLocalObjComplete(revWalk.parseAny(r.getObjectId())); } catch (IOException readError) { throw new TransportException(MessageFormat.format(JGitText.get().localRefIsMissingObjects, r.getName()), readError); } } for (ObjectId id : have) { try { markLocalObjComplete(revWalk.parseAny(id)); } catch (IOException readError) { throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionMissingAssumed, id.name()), readError); } } }
private void processTree(RevObject obj) throws TransportException { try { treeWalk.reset(obj); while (treeWalk.next()) { final FileMode mode = treeWalk.getFileMode(0); final int sType = mode.getObjectType(); switch (sType) { case Constants.OBJ_BLOB: case Constants.OBJ_TREE: treeWalk.getObjectId(idBuffer, 0); needs(revWalk.lookupAny(idBuffer, sType)); continue; default: if (FileMode.GITLINK.equals(mode)) continue; treeWalk.getObjectId(idBuffer, 0); throw new CorruptObjectException(MessageFormat.format(JGitText.get().invalidModeFor , mode, idBuffer.name(), treeWalk.getPathString(), obj.getId().name())); } } } catch (IOException ioe) { throw new TransportException(MessageFormat.format(JGitText.get().cannotReadTree, obj.name()), ioe); } obj.add(COMPLETE); }