public static ArrayMemory valueOf(Ref ref) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("name").assign(ref.getName()); memory.refOfIndex("peeled").assign(ref.isPeeled()); memory.refOfIndex("symbolic").assign(ref.isSymbolic()); memory.refOfIndex("objectId").assign(valueOf(ref.getObjectId())); memory.refOfIndex("storage").assign(valueOf(ref.getStorage())); return memory; }
/** {@inheritDoc} */ @Override public boolean isPeeled() { return getLeaf().isPeeled(); }
/** * Create a command to create, update or delete a reference. * <p> * At least one of {@code oldRef} or {@code newRef} must be supplied. * * @param oldRef * expected value. Null if the ref should not exist. * @param newRef * desired value, must be peeled if not null and not symbolic. * Null to delete the ref. */ public Command(@Nullable Ref oldRef, @Nullable Ref newRef) { this.oldRef = oldRef; this.newRef = newRef; this.cmd = null; this.result = NOT_ATTEMPTED; if (oldRef == null && newRef == null) { throw new IllegalArgumentException(); } if (newRef != null && !newRef.isPeeled() && !newRef.isSymbolic()) { throw new IllegalArgumentException(); } if (oldRef != null && newRef != null && !oldRef.getName().equals(newRef.getName())) { throw new IllegalArgumentException(); } }
/** {@inheritDoc} */ @Override public Ref peel(Ref ref) throws IOException { Ref oldLeaf = ref.getLeaf(); if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) { return ref; } return recreate(ref, doPeel(oldLeaf)); }
boolean peeled = false; for (Ref r : refs) { if (r.getStorage().isPacked() && r.isPeeled()) { peeled = true; break;
private static void cleanupPeeledRef(DirCacheEditor ed, Ref ref) { if (ref != null && !ref.isSymbolic() && (!ref.isPeeled() || ref.getPeeledObjectId() != null)) { ed.add(new DeletePath(peeledPath(ref.getName()))); } }
if (!ref.isPeeled()) { throw new IOException(JGitText.get().peeledRefIsRequired); } else if (id1 == null) { ObjectId id1 = ref.getObjectId(); ObjectId id2 = ref.getPeeledObjectId(); if (!ref.isPeeled()) { throw new IOException(JGitText.get().peeledRefIsRequired); } else if (id1 == null || id2 == null) {
/** * Make sure a ref is peeled and has the Storage PACKED. If the given ref * has this attributes simply return it. Otherwise create a new peeled * {@link ObjectIdRef} where Storage is set to PACKED. * * @param f * @return a ref for Storage PACKED having the same name, id, peeledId as f * @throws MissingObjectException * @throws IOException */ private Ref peeledPackedRef(Ref f) throws MissingObjectException, IOException { if (f.getStorage().isPacked() && f.isPeeled()) { return f; } if (!f.isPeeled()) { f = peel(f); } ObjectId peeledObjectId = f.getPeeledObjectId(); if (peeledObjectId != null) { return new ObjectIdRef.PeeledTag(PACKED, f.getName(), f.getObjectId(), peeledObjectId); } else { return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(), f.getObjectId()); } }
/** {@inheritDoc} */ @Override public Ref peel(Ref ref) throws IOException { final Ref leaf = ref.getLeaf(); if (leaf.isPeeled() || leaf.getObjectId() == null) return ref; ObjectIdRef newLeaf = doPeel(leaf); // Try to remember this peeling in the cache, so we don't have to do // it again in the future, but only if the reference is unchanged. if (leaf.getStorage().isLoose()) { RefList<LooseRef> curList = looseRefs.get(); int idx = curList.find(leaf.getName()); if (0 <= idx && curList.get(idx) == leaf) { LooseRef asPeeled = ((LooseRef) leaf).peel(newLeaf); RefList<LooseRef> newList = curList.set(idx, asPeeled); looseRefs.compareAndSet(curList, newList); } } return recreate(ref, newLeaf); }
/** {@inheritDoc} */ @Override public Ref peel(Ref ref) throws IOException { final Ref oldLeaf = ref.getLeaf(); if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) return ref; Ref newLeaf = doPeel(oldLeaf); RefCache cur = read(); int idx = cur.ids.find(oldLeaf.getName()); if (0 <= idx && cur.ids.get(idx) == oldLeaf) { RefList<Ref> newList = cur.ids.set(idx, newLeaf); cache.compareAndSet(cur, new RefCache(newList, cur)); cachePeeledState(oldLeaf, newLeaf); } return recreate(ref, newLeaf); }
/** {@inheritDoc} */ @Override public Ref peel(Ref ref) throws IOException { Ref i = ref.getLeaf(); ObjectId id = i.getObjectId(); if (i.isPeeled() || id == null) { return ref; } try (RevWalk rw = new RevWalk(repo)) { RevObject obj = rw.parseAny(id); if (obj instanceof RevTag) { ObjectId p = rw.peel(obj).copy(); i = new ObjectIdRef.PeeledTag(PACKED, i.getName(), id, p); } else { i = new ObjectIdRef.PeeledNonTag(PACKED, i.getName(), id); } } return recreate(ref, i); }
if(!ref.isPeeled()) ref = getRepository().getRefDatabase().peel(ref);
if (!ref.isPeeled()) ref = db.getRefDatabase().peel(ref);
/** {@inheritDoc} */ @Override public boolean isPeeled() { return getLeaf().isPeeled(); }
public boolean isPeeled() { return getLeaf().isPeeled(); }
/** {@inheritDoc} */ @Override public Ref peel(Ref ref) throws IOException { Ref oldLeaf = ref.getLeaf(); if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) { return ref; } return recreate(ref, doPeel(oldLeaf)); }
private static void cleanupPeeledRef(DirCacheEditor ed, Ref ref) { if (ref != null && !ref.isSymbolic() && (!ref.isPeeled() || ref.getPeeledObjectId() != null)) { ed.add(new DeletePath(peeledPath(ref.getName()))); } }
private static void cleanupPeeledRef(DirCacheEditor ed, Ref ref) { if (ref != null && !ref.isSymbolic() && (!ref.isPeeled() || ref.getPeeledObjectId() != null)) { ed.add(new DeletePath(peeledPath(ref.getName()))); } }
@Override public Ref peel(Ref ref) throws IOException { final Ref oldLeaf = ref.getLeaf(); if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) return ref; Ref newLeaf = doPeel(oldLeaf); RefCache cur = read(); int idx = cur.ids.find(oldLeaf.getName()); if (0 <= idx && cur.ids.get(idx) == oldLeaf) { RefList<Ref> newList = cur.ids.set(idx, newLeaf); cache.compareAndSet(cur, new RefCache(newList, cur)); cachePeeledState(oldLeaf, newLeaf); } return recreate(ref, newLeaf); }