/** * Get a specific entry. * * @param path * the path to search for. * @return the entry for the given <code>path</code>. */ public DirCacheEntry getEntry(String path) { final int i = findEntry(path); return i < 0 ? null : sortedEntries[i]; }
/** * Locate the position a path's entry is at in the index. * <p> * If there is at least one entry in the index for this path the position of * the lowest stage is returned. Subsequent stages can be identified by * testing consecutive entries until the path differs. * <p> * If no path matches the entry -(position+1) is returned, where position is * the location it would have gone within the index. * * @param p * the byte array starting with the path to search for. * @param pLen * the length of the path in bytes * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. * @since 3.4 */ public int findEntry(byte[] p, int pLen) { return findEntry(0, p, pLen); }
/** * Locate the position a path's entry is at in the index. For details refer * to #findEntry(byte[], int). * * @param path * the path to search for. * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. */ public int findEntry(String path) { final byte[] p = Constants.encode(path); return findEntry(p, p.length); }
/** * Recursively get all entries within a subtree. * * @param path * the subtree path to get all entries within. * @return all entries recursively contained within the subtree. */ public DirCacheEntry[] getEntriesWithin(String path) { if (path.length() == 0) { DirCacheEntry[] r = new DirCacheEntry[entryCnt]; System.arraycopy(sortedEntries, 0, r, 0, entryCnt); return r; } if (!path.endsWith("/")) //$NON-NLS-1$ path += "/"; //$NON-NLS-1$ final byte[] p = Constants.encode(path); final int pLen = p.length; int eIdx = findEntry(p, pLen); if (eIdx < 0) eIdx = -(eIdx + 1); final int lastIdx = nextEntry(p, pLen, eIdx); final DirCacheEntry[] r = new DirCacheEntry[lastIdx - eIdx]; System.arraycopy(sortedEntries, eIdx, r, 0, r.length); return r; }
while (editIdx < edits.size()) { PathEdit e = edits.get(editIdx++); int eIdx = cache.findEntry(lastIdx, e.path, e.path.length); final boolean missing = eIdx < 0; if (eIdx < 0)
/** * Get a specific entry. * * @param path * the path to search for. * @return the entry for the given <code>path</code>. */ public DirCacheEntry getEntry(final String path) { final int i = findEntry(path); return i < 0 ? null : sortedEntries[i]; }
/** * Get a specific entry. * * @param path * the path to search for. * @return the entry for the given <code>path</code>. */ public DirCacheEntry getEntry(String path) { final int i = findEntry(path); return i < 0 ? null : sortedEntries[i]; }
int entryIdx = dc.findEntry(conflict); if (entryIdx >= 0) { while (entryIdx < dc.getEntryCount()) {
/** * Locate the position a path's entry is at in the index. * <p> * If there is at least one entry in the index for this path the position of * the lowest stage is returned. Subsequent stages can be identified by * testing consecutive entries until the path differs. * <p> * If no path matches the entry -(position+1) is returned, where position is * the location it would have gone within the index. * * @param p * the byte array starting with the path to search for. * @param pLen * the length of the path in bytes * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. * @since 3.4 */ public int findEntry(byte[] p, int pLen) { return findEntry(0, p, pLen); }
/** * Locate the position a path's entry is at in the index. * <p> * If there is at least one entry in the index for this path the position of * the lowest stage is returned. Subsequent stages can be identified by * testing consecutive entries until the path differs. * <p> * If no path matches the entry -(position+1) is returned, where position is * the location it would have gone within the index. * * @param p * the byte array starting with the path to search for. * @param pLen * the length of the path in bytes * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. * @since 3.4 */ public int findEntry(byte[] p, int pLen) { return findEntry(0, p, pLen); }
if (!repo.isBare()) { DirCache dc = repo.readDirCache(); int entry = dc.findEntry(path); if (0 <= entry) gen.push(null, dc.getEntry(entry).getObjectId());
public static int findEntry(@Nonnull String path, @Nonnull DirCache cache) { return cache.findEntry(TreeUtils.normalizeTreePath(path)); }
public static int findEntry(String path, DirCache cache) { return cache.findEntry(normalizeNodePath(path)); }
/** * Locate the position a path's entry is at in the index. For details refer * to #findEntry(byte[], int). * * @param path * the path to search for. * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. */ public int findEntry(final String path) { final byte[] p = Constants.encode(path); return findEntry(p, p.length); }
public static int findEntry(String path, DirCache cache) { return cache.findEntry(normalizeNodePath(path)); }
/** * Locate the position a path's entry is at in the index. For details refer * to #findEntry(byte[], int). * * @param path * the path to search for. * @return if >= 0 then the return value is the position of the entry in * the index; pass to {@link #getEntry(int)} to obtain the entry * information. If < 0 the entry does not exist in the index. */ public int findEntry(String path) { final byte[] p = Constants.encode(path); return findEntry(p, p.length); }
public static boolean isNonEmptyDirectory(@Nonnull String path, @Nonnull DirCache cache) { path = TreeUtils.normalizeTreePath(path) + "/"; if(path.equals("/")) // if it is root return true; int startIndex = cache.findEntry(path); // find the index of this path if(startIndex < 0) // when the path is a directory, its index is negative startIndex = -(startIndex + 1); // indices of children paths inside this directory start from -(index + 1) if(startIndex >= cache.getEntryCount()) // if beyond the total return false; String childPath = cache.getEntry(startIndex).getPathString(); // potentially the first child inside this directory return childPath.startsWith(path); // if it is indeed a child path, then this directory is non-trivial }
/** * Recursively get all entries within a subtree. * * @param path * the subtree path to get all entries within. * @return all entries recursively contained within the subtree. */ public DirCacheEntry[] getEntriesWithin(String path) { if (path.length() == 0) { DirCacheEntry[] r = new DirCacheEntry[entryCnt]; System.arraycopy(sortedEntries, 0, r, 0, entryCnt); return r; } if (!path.endsWith("/")) //$NON-NLS-1$ path += "/"; //$NON-NLS-1$ final byte[] p = Constants.encode(path); final int pLen = p.length; int eIdx = findEntry(p, pLen); if (eIdx < 0) eIdx = -(eIdx + 1); final int lastIdx = nextEntry(p, pLen, eIdx); final DirCacheEntry[] r = new DirCacheEntry[lastIdx - eIdx]; System.arraycopy(sortedEntries, eIdx, r, 0, r.length); return r; }
public static boolean isNonEmptyDirectory(String path, DirCache cache) { path = normalizeNodePath(path) + "/"; if(path.equals("/")) // if it is root return true; int startIndex = cache.findEntry(path); // find the index of this path if(startIndex < 0) // when the path is a directory, its index is negative startIndex = -(startIndex + 1); // indices of children paths inside this directory start from -(index + 1) if(startIndex >= cache.getEntryCount()) // if beyond the total return false; String childPath = cache.getEntry(startIndex).getPathString(); // potentially the first child inside this directory return childPath.startsWith(path); // if it is indeed a child path, then this directory is non-trivial }
public static boolean isNonEmptyDirectory(String path, DirCache cache) { path = normalizeNodePath(path) + "/"; if(path.equals("/")) // if it is root return true; int startIndex = cache.findEntry(path); // find the index of this path if(startIndex < 0) // when the path is a directory, its index is negative startIndex = -(startIndex + 1); // indices of children paths inside this directory start from -(index + 1) if(startIndex >= cache.getEntryCount()) // if beyond the total return false; String childPath = cache.getEntry(startIndex).getPathString(); // potentially the first child inside this directory return childPath.startsWith(path); // if it is indeed a child path, then this directory is non-trivial }