/** * Reverts the worktree after an unsuccessful merge. We know that for all * modified files the old content was in the old index and the index * contained only stage 0. In case if inCore operation just clear the * history of modified files. * * @throws java.io.IOException * @throws org.eclipse.jgit.errors.CorruptObjectException * @throws org.eclipse.jgit.errors.NoWorkTreeException * @since 3.4 */ protected void cleanUp() throws NoWorkTreeException, CorruptObjectException, IOException { if (inCore) { modifiedFiles.clear(); return; } DirCache dc = nonNullRepo().readDirCache(); Iterator<String> mpathsIt=modifiedFiles.iterator(); while(mpathsIt.hasNext()) { String mpath = mpathsIt.next(); DirCacheEntry entry = dc.getEntry(mpath); if (entry != null) { DirCacheCheckout.checkoutEntry(db, entry, reader, false, checkoutMetadata.get(mpath)); } mpathsIt.remove(); } }
if (!readDirCache().hasUnmergedPaths()) { if (!readDirCache().hasUnmergedPaths()) { if (!readDirCache().hasUnmergedPaths()) {
/** * Create a generator to walk over the submodule entries currently in the * index * * The {@code .gitmodules} file is read from the index. * * @param repository * a {@link org.eclipse.jgit.lib.Repository} object. * @return generator over submodule index entries. The caller is responsible * for calling {@link #close()}. * @throws java.io.IOException */ public static SubmoduleWalk forIndex(Repository repository) throws IOException { @SuppressWarnings("resource") // The caller closes it SubmoduleWalk generator = new SubmoduleWalk(repository); try { DirCache index = repository.readDirCache(); generator.setTree(new DirCacheIterator(index)); } catch (IOException e) { generator.close(); throw e; } return generator; }
int estIndexSize, final String title) throws IOException { dirCache = repository.readDirCache();
gen.push(null, repo.resolve(Constants.HEAD)); if (!repo.isBare()) { DirCache dc = repo.readDirCache(); int entry = dc.findEntry(path); if (0 <= entry)
newTree = new DirCacheIterator(repo.readDirCache()); } else { if (oldTree == null) oldTree = new DirCacheIterator(repo.readDirCache()); if (newTree == null) newTree = new FileTreeIterator(repo);
@Override protected void run() throws Exception { final int cnt = 100; final long start = System.currentTimeMillis(); for (int i = 0; i < cnt; i++) db.readDirCache(); final long end = System.currentTimeMillis(); outw.print(" "); //$NON-NLS-1$ outw.println(MessageFormat.format(CLIText.get().averageMSPerRead, valueOf((end - start) / cnt))); } }
DirCache dc = repo.readDirCache(); boolean hasUnmergedPaths = dc.hasUnmergedPaths(); if (hasUnmergedPaths)
@Override protected void run() throws Exception { final DirCache cache = db.readDirCache(); final DirCacheTree tree = cache.getCacheTree(true); show(tree); }
/** * Reverts the worktree after an unsuccessful merge. We know that for all * modified files the old content was in the old index and the index * contained only stage 0. In case if inCore operation just clear the * history of modified files. * * @throws IOException * @throws CorruptObjectException * @throws NoWorkTreeException * @since 3.4 */ protected void cleanUp() throws NoWorkTreeException, CorruptObjectException, IOException { if (inCore) { modifiedFiles.clear(); return; } DirCache dc = db.readDirCache(); Iterator<String> mpathsIt=modifiedFiles.iterator(); while(mpathsIt.hasNext()) { String mpath=mpathsIt.next(); DirCacheEntry entry = dc.getEntry(mpath); if (entry != null) DirCacheCheckout.checkoutEntry(db, entry, reader); mpathsIt.remove(); } }
/** * Reverts the worktree after an unsuccessful merge. We know that for all * modified files the old content was in the old index and the index * contained only stage 0. In case if inCore operation just clear the * history of modified files. * * @throws java.io.IOException * @throws org.eclipse.jgit.errors.CorruptObjectException * @throws org.eclipse.jgit.errors.NoWorkTreeException * @since 3.4 */ protected void cleanUp() throws NoWorkTreeException, CorruptObjectException, IOException { if (inCore) { modifiedFiles.clear(); return; } DirCache dc = nonNullRepo().readDirCache(); Iterator<String> mpathsIt=modifiedFiles.iterator(); while(mpathsIt.hasNext()) { String mpath = mpathsIt.next(); DirCacheEntry entry = dc.getEntry(mpath); if (entry != null) { DirCacheCheckout.checkoutEntry(db, entry, reader, false, checkoutMetadata.get(mpath)); } mpathsIt.remove(); } }
private AbstractTreeIterator getTreeIterator(Repository repo, String commit) throws IOException { if (commit.equals("dircache")) { return new DirCacheIterator(repo.readDirCache()); } if (commit.equals("filetree")) { return new FileTreeIterator(repo); } ObjectId treeId = repo.resolve(commit + "^{tree}"); if (treeId == null) { throw new NullPointerException(); } CanonicalTreeParser treeIter = new CanonicalTreeParser(); ObjectReader reader = repo.newObjectReader(); treeIter.reset(reader, treeId); return treeIter; }
private AbstractTreeIterator getTreeIterator(Repository repo, String commit) throws IOException { if (commit.equals("dircache")) { return new DirCacheIterator(repo.readDirCache()); } if (commit.equals("filetree")) { return new FileTreeIterator(repo); } ObjectId treeId = repo.resolve(commit + "^{tree}"); if (treeId == null) { throw new NullPointerException(); } CanonicalTreeParser treeIter = new CanonicalTreeParser(); ObjectReader reader = repo.newObjectReader(); treeIter.reset(reader, treeId); return treeIter; }
@Override protected void run() throws Exception { final DirCache cache = db.readDirCache(); final DirCacheTree tree = cache.getCacheTree(false); if (tree == null) throw die(CLIText.get().noTREESectionInIndex); show(tree); }
/** * Create a generator to walk over the submodule entries currently in the * index * * The {@code .gitmodules} file is read from the index. * * @param repository * @return generator over submodule index entries * @throws IOException */ public static SubmoduleWalk forIndex(Repository repository) throws IOException { SubmoduleWalk generator = new SubmoduleWalk(repository); try { DirCache index = repository.readDirCache(); generator.setTree(new DirCacheIterator(index)); } catch (IOException e) { generator.close(); throw e; } return generator; }
/** * Create a generator to walk over the submodule entries currently in the * index * * The {@code .gitmodules} file is read from the index. * * @param repository * a {@link org.eclipse.jgit.lib.Repository} object. * @return generator over submodule index entries. The caller is responsible * for calling {@link #close()}. * @throws java.io.IOException */ public static SubmoduleWalk forIndex(Repository repository) throws IOException { @SuppressWarnings("resource") // The caller closes it SubmoduleWalk generator = new SubmoduleWalk(repository); try { DirCache index = repository.readDirCache(); generator.setTree(new DirCacheIterator(index)); } catch (IOException e) { generator.close(); throw e; } return generator; }
@Override protected void run() throws Exception { final DirCache cache = db.readDirCache(); if (!cache.lock()) throw die(CLIText.get().failedToLockIndex); cache.read(); cache.write(); if (!cache.commit()) throw die(CLIText.get().failedToCommitIndex); } }
fmt = new SimpleDateFormat("yyyy-MM-dd,HH:mm:ss.SSS"); //$NON-NLS-1$ final DirCache cache = db.readDirCache(); for (int i = 0; i < cache.getEntryCount(); i++) { final DirCacheEntry ent = cache.getEntry(i);
private boolean isTracked(File file, Repository repo) throws IOException { ObjectId objectId = repo.resolve(Constants.HEAD); RevTree tree; if (objectId != null) tree = new RevWalk(repo).parseTree(objectId); else tree = null; TreeWalk treeWalk = new TreeWalk(repo); treeWalk.setRecursive(true); if (tree != null) treeWalk.addTree(tree); else treeWalk.addTree(new EmptyTreeIterator()); treeWalk.addTree(new DirCacheIterator(repo.readDirCache())); treeWalk.setFilter(PathFilterGroup.createFromStrings(Collections.singleton( Repository.stripWorkDir(repo.getWorkTree(), file)))); return treeWalk.next(); }
public boolean isTracked(String path) throws IOException { ObjectId objectId = localRepo.resolve(Constants.HEAD); RevTree tree; RevWalk walk = null; if (objectId != null) { walk = new RevWalk(localRepo); tree = walk.parseTree(objectId); } else { tree = null; } try (TreeWalk treeWalk = new TreeWalk(localRepo)) { treeWalk.setRecursive(true); if (tree != null) treeWalk.addTree(tree); else treeWalk.addTree(new EmptyTreeIterator()); treeWalk.addTree(new DirCacheIterator(localRepo.readDirCache())); treeWalk.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path))); return treeWalk.next(); } finally { if (walk != null) walk.close(); } }