/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { return "AbbreviatedObjectId[" + name() + "]"; //$NON-NLS-1$ } }
/** * Create string suitable for debug logging containing the log index and * abbreviated ObjectId. * * @return string suitable for debug logging containing the log index and * abbreviated ObjectId. */ @SuppressWarnings("boxing") public String describeForLog() { return String.format("%5d/%s", index, abbreviate(6).name()); //$NON-NLS-1$ }
/** * Construct a MissingObjectException for the specified object id. Expected * type is reported to simplify tracking down the problem. * * @param id * SHA-1 * @param candidates * the candidate matches returned by the ObjectReader. */ public AmbiguousObjectException(final AbbreviatedObjectId id, final Collection<ObjectId> candidates) { super(MessageFormat.format(JGitText.get().ambiguousObjectAbbreviation, id.name())); this.missing = id; this.candidates = candidates; }
/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { StringBuilder r = new StringBuilder(); r.append("Candidate["); r.append(sourcePath.getPath()); if (sourceCommit != null) r.append(" @ ").append(sourceCommit.abbreviate(6).name()); if (regionList != null) r.append(" regions:").append(regionList); r.append("]"); return r.toString(); }
/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TrackingRefUpdate["); sb.append(remoteName); sb.append(" -> "); sb.append(localName); if (forceUpdate) sb.append(" (forced)"); sb.append(" "); sb.append(oldObjectId == null ? "" : oldObjectId.abbreviate(7).name()); sb.append(".."); sb.append(newObjectId == null ? "" : newObjectId.abbreviate(7).name()); sb.append("]"); return sb.toString(); } }
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); }
private String longDescription(Ref tag, int depth, ObjectId tip) throws IOException { return String.format( "%s-%d-g%s", tag.getName().substring(R_TAGS.length()), //$NON-NLS-1$ Integer.valueOf(depth), w.getObjectReader().abbreviate(tip) .name()); }
/** * 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(AbbreviatedObjectId id, int type) { super(MessageFormat.format(JGitText.get().missingObject, Constants .typeString(type), id.name())); missing = null; }
static String str(ObjectId c) { if (c instanceof LogIndex) { return ((LogIndex) c).describeForLog(); } else if (c != null) { return c.abbreviate(8).name(); } return "-"; //$NON-NLS-1$ } }
private String getAbbrevCommitId(ObjectReader objectReader, RevCommit headCommit, int abbrevLength) throws GitCommitIdExecutionException { try { AbbreviatedObjectId abbreviatedObjectId = objectReader.abbreviate(headCommit, abbrevLength); return abbreviatedObjectId.name(); } catch (IOException e) { throw new GitCommitIdExecutionException("Unable to abbreviate commit id! " + "You may want to investigate the <abbrevLength/> element in your configuration.", e); } }
/** * <p>The (possibly) "g" prefixed <strong>abbreviated</strong> object id of a commit.</p> * <p> * The "g" prefix is prepended to be compatible with git's describe output, please refer to * <b>man git-describe</b> to check why it's included. * </p> * <p> * The "g" prefix is used when a tag is defined on this result. If it's not, this method yields a plain commit id hash. * This is following git's behaviour - so any git tooling should be happy with this output. * </p> * <p> * Notes about the abbreviated object id: * Git will try to use your given abbrev length, but when it's too short to guarantee uniqueness - * a longer one will be used (which WILL guarantee uniqueness). * If you need the full commit id, it's always available via {@link pl.project13.jgit.DescribeResult#commitObjectId()}. * </p> */ @Nullable public String prefixedCommitId() { if (abbreviatedObjectId.isPresent()) { String name = abbreviatedObjectId.get().name(); return gPrefixedCommitId(name); } else if (commitId.isPresent()) { String name = commitId.get().name(); return gPrefixedCommitId(name); } else { return null; } }
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(); }
sb.append(step.getAction().toToken()); sb.append(" "); //$NON-NLS-1$ sb.append(step.getCommit().name()); sb.append(" "); //$NON-NLS-1$ sb.append(step.getShortMessage().trim());
private static void format(StringBuilder s, @Nullable Ref r, String n) { if (r == null) { s.append(n); } else if (r.isSymbolic()) { s.append(r.getTarget().getName()); } else { ObjectId id = r.getObjectId(); if (id != null) { s.append(id.abbreviate(8).name()); } } } }
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$ }
String fanOut = id.name().substring(0, 2); String[] entries = new File(getDirectory(), fanOut).list(); if (entries != null) {
/** * Set the action. It's not allowed to set a non-comment action on a line * which was a comment line before. But you are allowed to set the comment * action on a non-comment line and afterwards change the action back to * non-comment. * * @param newAction * a {@link org.eclipse.jgit.lib.RebaseTodoLine.Action} object. * @throws org.eclipse.jgit.errors.IllegalTodoFileModification * on attempt to set a non-comment action on a line which was a * comment line before. */ public void setAction(Action newAction) throws IllegalTodoFileModification { if (!Action.COMMENT.equals(action) && Action.COMMENT.equals(newAction)) { // transforming from non-comment to comment if (comment == null) // no comment was explicitly set. Take the old line as comment // text comment = "# " + action.token + " " //$NON-NLS-1$ //$NON-NLS-2$ + ((commit == null) ? "null" : commit.name()) + " " //$NON-NLS-1$ //$NON-NLS-2$ + ((shortMessage == null) ? "null" : shortMessage); //$NON-NLS-1$ } else if (Action.COMMENT.equals(action) && !Action.COMMENT.equals(newAction)) { // transforming from comment to non-comment if (commit == null) throw new IllegalTodoFileModification(MessageFormat.format( JGitText.get().cannotChangeActionOnComment, action, newAction)); } this.action = newAction; }
KetchReplica.log.error(String.format( "Cannot fetch %s (%s) from %s", //$NON-NLS-1$ remoteId.abbreviate(8).name(), refName, replica.describeForLog()), fetchErr); throw new MissingObjectException(remoteId, OBJ_COMMIT);
private RebaseResult stop(RevCommit commitToPick, RebaseResult.Status status) throws IOException { PersonIdent author = commitToPick.getAuthorIdent(); String authorScript = toAuthorScript(author); rebaseState.createFile(AUTHOR_SCRIPT, authorScript); rebaseState.createFile(MESSAGE, commitToPick.getFullMessage()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (DiffFormatter df = new DiffFormatter(bos)) { df.setRepository(repo); df.format(commitToPick.getParent(0), commitToPick); } rebaseState.createFile(PATCH, new String(bos.toByteArray(), UTF_8)); rebaseState.createFile(STOPPED_SHA, repo.newObjectReader() .abbreviate( commitToPick).name()); // Remove cherry pick state file created by CherryPickCommand, it's not // needed for rebase repo.writeCherryPickHead(null); return RebaseResult.result(status, commitToPick); }
String cherryPickName = srcCommit.getId().abbreviate(7).name() + " " + srcCommit.getShortMessage(); //$NON-NLS-1$