/** {@inheritDoc} */ @Override public void skip() throws CorruptObjectException { if (currentSubtree != null) builder.keep(ptr, currentSubtree.getEntrySpan()); else builder.keep(ptr, 1); next(1); }
/** * Get the file mode of the given path in the index * * @param path a {@link java.lang.String} object. * @return file mode */ public FileMode getIndexMode(String path) { final DirCacheEntry entry = dirCache.getEntry(path); return entry != null ? entry.getFileMode() : FileMode.MISSING; }
DirCacheIterator(DirCacheIterator p, DirCacheTree dct) { super(p, p.path, p.pathLen + 1); cache = p.cache; tree = dct; treeStart = p.ptr; treeEnd = treeStart + tree.getEntrySpan(); subtreeId = p.subtreeId; ptr = p.ptr; parseEntry(); }
/** {@inheritDoc} */ @Override public void stopWalk() { final int cur = ptr; final int cnt = cache.getEntryCount(); if (cur < cnt) builder.keep(cur, cnt - cur); }
/** {@inheritDoc} */ @Override public void next(int delta) { while (--delta >= 0) { if (currentSubtree != null) ptr += currentSubtree.getEntrySpan(); else ptr++; if (eof()) break; parseEntry(); } }
/** * Set the cached size (in bytes) of this file. * * @param sz * new cached size of the file, as bytes. */ public void setLength(long sz) { setLength((int) sz); }
/** {@inheritDoc} */ @Override public void reset() { if (!first()) { ptr = treeStart; nextSubtreePos = 0; currentEntry = null; currentSubtree = null; if (!eof()) parseEntry(); } }
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path from one entry to another, * supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. */ public void copyMetaData(DirCacheEntry src) { copyMetaData(src, false); }
/** * Returns whether this entry should be skipped from the working tree. * * @return true if this entry should be skipepd. */ public boolean isSkipWorkTree() { return (getExtendedFlags() & SKIP_WORKTREE) != 0; }
/** {@inheritDoc} */ @Override public int idOffset() { if (currentSubtree != null) return 0; if (currentEntry != null) return currentEntry.idOffset(); return 0; }
@Override public int compare(PathEdit o1, PathEdit o2) { final byte[] a = o1.path; final byte[] b = o2.path; return cmp(a, a.length, b, b.length); } };
/** * Create a new empty index which is never stored on disk. * * @return an empty cache which has no backing store file. The cache may not * be read or written, but it may be queried and updated (in * memory). */ public static DirCache newInCore() { return new DirCache(null, null); }
int nextEntry(byte[] p, int pLen, int nextIdx) { while (nextIdx < entryCnt) { final DirCacheEntry next = sortedEntries[nextIdx]; if (!DirCacheTree.peq(p, next.path, pLen)) break; nextIdx++; } return nextIdx; }
/** {@inheritDoc} */ @Override public boolean hasId() { if (currentSubtree != null) return currentSubtree.isValid(); return currentEntry != null; }
/** * Create a new editor to recreate this cache. * <p> * Callers should add commands to the editor, then use * {@link org.eclipse.jgit.dircache.DirCacheEditor#finish()} to update this * instance. * * @return a new builder instance for this cache. */ public DirCacheEditor editor() { return new DirCacheEditor(this, entryCnt + 16); }
/** * Set the cached creation time of this file, using milliseconds. * * @param when * new cached creation time of the file, in milliseconds. */ public void setCreationTime(long when) { encodeTS(P_CTIME, when); }
/** {@inheritDoc} */ @Override public void back(int delta) { while (--delta >= 0) { if (currentSubtree != null) nextSubtreePos--; ptr--; parseEntry(false); if (currentSubtree != null) ptr -= currentSubtree.getEntrySpan() - 1; } }
@Override public void apply(DirCacheEntry ent) { ent.copyMetaData(entry); } });