/** * Determine if this ObjectId has exactly the same value as another. * * @param other * the other id to compare to. May be null. * @return true only if both ObjectIds have identical bits. */ public final boolean equals(AnyObjectId other) { return other != null ? equals(this, other) : false; }
private static boolean sameNote(Note a, Note b) { if (a == null && b == null) return true; return a != null && b != null && AnyObjectId.equals(a, b); }
/** {@inheritDoc} */ @Override public final boolean equals(Object o) { if (o instanceof AnyObjectId) return equals((AnyObjectId) o); else return false; }
/** * Lookup an existing mapping. * * @param toFind * the object identifier to find. * @return the instance mapped to toFind, or null if no mapping exists. */ public V get(AnyObjectId toFind) { final int msk = mask; int i = toFind.w1 & msk; final V[] tbl = table; V obj; while ((obj = tbl[i]) != null) { if (AnyObjectId.equals(obj, toFind)) return obj; i = (i + 1) & msk; } return null; }
boolean contains(AnyObjectId toFind) { int i = index(toFind); for (int n = 0; n < MAX_CHAIN; n++) { ObjectId obj = ids.get(i); if (obj == null) break; if (AnyObjectId.equals(obj, toFind)) return true; if (++i == ids.length()) i = 0; } return false; }
private static boolean equals(@Nullable ObjectId a, LogIndex b) { return a != null && b != null && AnyObjectId.equals(a, b); }
private RefUpdate.Result decode(ReceiveCommand.Result status) { switch (status) { case OK: if (AnyObjectId.equals(oldObjectId, newObjectId)) return RefUpdate.Result.NO_CHANGE; switch (getType()) {
private static boolean sameContent(Note a, Note b) { if (a == null && b == null) return true; return a != null && b != null && AnyObjectId.equals(a.getData(), b.getData()); }
boolean add(AnyObjectId toAdd) { int i = index(toAdd); for (int n = 0; n < MAX_CHAIN;) { ObjectId obj = ids.get(i); if (obj == null) { if (ids.compareAndSet(i, null, toAdd.copy())) return true; else continue; } if (AnyObjectId.equals(obj, toAdd)) return true; if (++i == ids.length()) i = 0; n++; } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof Map.Entry) { final Object key = ((Map.Entry) obj).getKey(); final Object val = ((Map.Entry) obj).getValue(); if (key instanceof String && val instanceof Ref) { final Ref r = (Ref) val; if (r.getName().equals(ref.getName())) { final ObjectId a = r.getObjectId(); final ObjectId b = ref.getObjectId(); if (a != null && b != null && AnyObjectId.equals(a, b)) return true; } } } return false; }
private static boolean isExpectedValue(Map<String, Ref> adv, RemoteRefUpdate u) { Ref r = adv.get(u.getRemoteName()); if (!AnyObjectId.equals(getId(r), u.getExpectedOldObjectId())) { ((RemoteCommand) u).cmd.setResult(LOCK_FAILURE); return false; } return true; }
if (AnyObjectId.equals(obj, newValue)) return obj; i = (i + 1) & msk;
this.newSymref = newSymref; this.name = name; if (AnyObjectId.equals(ObjectId.zeroId(), oldId)) { type = Type.CREATE; } else if (newSymref != null) {
if (oldSymref == null) { type = Type.CREATE; } else if (!AnyObjectId.equals(ObjectId.zeroId(), newId)) { type = Type.UPDATE; } else {
/** * Update the type of this command by checking for fast-forward. * <p> * If the command's current type is UPDATE, a merge test will be performed * using the supplied RevWalk to determine if {@link #getOldId()} is fully * merged into {@link #getNewId()}. If some commits are not merged the * update type is changed to * {@link org.eclipse.jgit.transport.ReceiveCommand.Type#UPDATE_NONFASTFORWARD}. * * @param walk * an instance to perform the merge test with. The caller must * allocate and release this object. * @throws java.io.IOException * either oldId or newId is not accessible in the repository * used by the RevWalk. This usually indicates data corruption, * and the command cannot be processed. */ public void updateType(RevWalk walk) throws IOException { if (typeIsCorrect) return; if (type == Type.UPDATE && !AnyObjectId.equals(oldId, newId)) { RevObject o = walk.parseAny(oldId); RevObject n = walk.parseAny(newId); if (!(o instanceof RevCommit) || !(n instanceof RevCommit) || !walk.isMergedInto((RevCommit) o, (RevCommit) n)) setType(Type.UPDATE_NONFASTFORWARD); } typeIsCorrect = true; }
private static List<Ref> toNewRefs(RevWalk rw, List<ReceiveCommand> pending) throws IOException { List<Ref> refs = new ArrayList<>(pending.size()); for (ReceiveCommand cmd : pending) { String name = cmd.getRefName(); ObjectId newId = cmd.getNewId(); String newSymref = cmd.getNewSymref(); if (AnyObjectId.equals(ObjectId.zeroId(), newId) && newSymref == null) { refs.add(new ObjectIdRef.Unpeeled(NEW, name, null)); continue; } else if (newSymref != null) { refs.add(new SymbolicRef(name, new ObjectIdRef.Unpeeled(NEW, newSymref, null))); continue; } RevObject obj = rw.parseAny(newId); RevObject peel = null; if (obj instanceof RevTag) { peel = rw.peel(obj); } if (peel != null) { refs.add(new ObjectIdRef.PeeledTag(PACKED, name, newId, peel.copy())); } else { refs.add(new ObjectIdRef.PeeledNonTag(PACKED, name, newId)); } } return refs; }
if (AnyObjectId.equals(remoteId, ObjectId.zeroId())) {
private static boolean matchOld(ReceiveCommand cmd, @Nullable Ref ref) { if (ref == null) { return AnyObjectId.equals(ObjectId.zeroId(), cmd.getOldId()) && cmd.getOldSymref() == null; } else if (ref.isSymbolic()) { return ref.getTarget().getName().equals(cmd.getOldSymref()); } ObjectId id = ref.getObjectId(); if (id == null) { id = ObjectId.zeroId(); } return cmd.getOldId().equals(id); }
ObjectId oldId = getId(oldRef); ObjectId newId = tw.getObjectId(0); if (!AnyObjectId.equals(oldId, newId)) { delta.add(new ReceiveCommand(oldId, newId, name));
if (!AnyObjectId.equals(id, act)) { throw new TransportException(MessageFormat.format( JGitText.get().incorrectHashFor, id.name(), act.name(),