List of usage examples for org.eclipse.jgit.lib AnyObjectId equals
@Deprecated @SuppressWarnings("AmbiguousMethodReference") public static boolean equals(final AnyObjectId firstObjectId, final AnyObjectId secondObjectId)
From source file:com.google.gerrit.server.patch.PatchListKey.java
License:Apache License
private static boolean eq(final ObjectId a, final ObjectId b) { if (a == null && b == null) { return true; }//from ww w .j a v a2 s . c o m return a != null && b != null && AnyObjectId.equals(a, b); }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java
License:Eclipse Distribution License
private void verifyAndInsertLooseObject(final AnyObjectId id, final byte[] compressed) throws IOException { final ObjectLoader uol; try {/* www . jav a 2s. c om*/ uol = UnpackedObject.parse(compressed, id); } catch (CorruptObjectException parsingError) { // Some HTTP servers send back a "200 OK" status with an HTML // page that explains the requested file could not be found. // These servers are most certainly misconfigured, but many // of them exist in the world, and many of those are hosting // Git repositories. // // Since an HTML page is unlikely to hash to one of our loose // objects we treat this condition as a FileNotFoundException // and attempt to recover by getting the object from another // source. // final FileNotFoundException e; e = new FileNotFoundException(id.name()); e.initCause(parsingError); throw e; } final int type = uol.getType(); final byte[] raw = uol.getCachedBytes(); if (objCheck != null) { try { objCheck.check(type, raw); } catch (CorruptObjectException e) { throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionInvalid, Constants.typeString(type), id.name(), e.getMessage())); } } ObjectId act = inserter.insert(type, raw); if (!AnyObjectId.equals(id, act)) { throw new TransportException(MessageFormat.format(JGitText.get().incorrectHashFor, id.name(), act.name(), Constants.typeString(type), compressed.length)); } inserter.flush(); }
From source file:org.craftercms.studio.impl.v1.util.git.CherryPickCommandEx.java
License:Eclipse Distribution License
/** * Executes the {@code Cherry-Pick} command with all the options and * parameters collected by the setter methods (e.g. {@link #include(Ref)} of * this class. Each instance of this class should only be used for one * invocation of the command. Don't call this method twice on an instance. * * @return the result of the cherry-pick * @throws GitAPIException/* www. j ava2s. c om*/ * @throws WrongRepositoryStateException * @throws ConcurrentRefUpdateException * @throws UnmergedPathsException * @throws NoMessageException * @throws NoHeadException */ @Override public CherryPickResult call() throws GitAPIException { RevCommit newHead = null; List<Ref> cherryPickedRefs = new LinkedList<>(); checkCallable(); try (RevWalk revWalk = new RevWalk(repo)) { // get the head commit Ref headRef = repo.exactRef(Constants.HEAD); if (headRef == null) throw new NoHeadException(JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); newHead = revWalk.parseCommit(headRef.getObjectId()); // loop through all refs to be cherry-picked for (Ref src : commits) { // get the commit to be cherry-picked // handle annotated tags ObjectId srcObjectId = src.getPeeledObjectId(); if (srcObjectId == null) srcObjectId = src.getObjectId(); RevCommit srcCommit = revWalk.parseCommit(srcObjectId); Merger merger = strategy.newMerger(repo); if (merger.merge(newHead, srcCommit)) { if (AnyObjectId.equals(newHead.getTree().getId(), merger.getResultTreeId())) continue; DirCacheCheckout dco = new DirCacheCheckout(repo, newHead.getTree(), repo.lockDirCache(), merger.getResultTreeId()); dco.setFailOnConflict(true); dco.checkout(); if (!noCommit) newHead = new Git(getRepository()).commit().setMessage(srcCommit.getFullMessage()) .setReflogComment(reflogPrefix + " " //$NON-NLS-1$ + srcCommit.getShortMessage()) .setAuthor(srcCommit.getAuthorIdent()).setNoVerify(true).call(); cherryPickedRefs.add(src); } else { return CherryPickResult.CONFLICT; } } } catch (IOException e) { throw new JGitInternalException( MessageFormat.format(JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand, e), e); } return new CherryPickResult(newHead, cherryPickedRefs); }
From source file:org.eclipse.egit.core.internal.storage.CommitFileRevision.java
License:Open Source License
public ITag[] getTags() { final Collection<GitTag> ret = new ArrayList<GitTag>(); for (final Map.Entry<String, Ref> tag : db.getTags().entrySet()) { final ObjectId ref = tag.getValue().getPeeledObjectId(); if (ref == null) continue; if (!AnyObjectId.equals(ref, commit)) continue; ret.add(new GitTag(tag.getKey())); }/*from w w w .j ava 2 s.c o m*/ return ret.toArray(new ITag[ret.size()]); }
From source file:org.eclipse.orion.server.git.objects.Commit.java
License:Open Source License
private Map<String, Ref> getTagsForCommit() throws MissingObjectException, IOException { final Map<String, Ref> tags = new HashMap<String, Ref>(); for (final Entry<String, Ref> tag : db.getTags().entrySet()) { Ref ref = db.peel(tag.getValue()); ObjectId refId = ref.getPeeledObjectId(); if (refId == null) refId = ref.getObjectId();/*from ww w . j a v a 2 s . c o m*/ if (!AnyObjectId.equals(refId, revCommit)) continue; tags.put(tag.getKey(), tag.getValue()); } return tags; }
From source file:svnserver.repository.git.GitObject.java
License:GNU General Public License
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GitObject gitObject = (GitObject) o; return AnyObjectId.equals(object, gitObject.object); }