/** * Create a new in-core index representation. * <p> * The new index will be empty. Callers may wish to read from the on disk * file first with {@link #read()}. * * @param indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. */ public DirCache(File indexLocation, FS fs) { liveFile = indexLocation; clear(); }
throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clear(); else if (snapshot == null || snapshot.isModified(liveFile)) { try (SilentFileInputStream inStream = new SilentFileInputStream( liveFile)) { clear(); readFrom(inStream); } catch (FileNotFoundException fnfe) { clear();
/** * Create a new in-core index representation. * <p> * The new index will be empty. Callers may wish to read from the on disk * file first with {@link #read()}. * * @param indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. */ public DirCache(final File indexLocation, final FS fs) { liveFile = indexLocation; clear(); }
/** * Create a new in-core index representation. * <p> * The new index will be empty. Callers may wish to read from the on disk * file first with {@link #read()}. * * @param indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. */ public DirCache(File indexLocation, FS fs) { liveFile = indexLocation; clear(); }
throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clear(); else if (snapshot == null || snapshot.isModified(liveFile)) { try (SilentFileInputStream inStream = new SilentFileInputStream( liveFile)) { clear(); readFrom(inStream); } catch (FileNotFoundException fnfe) { clear();
editor.getDirCache().clear(); return Optional.empty();
private CommitBuilder amend(RevCommit old, CommitBuilder b) throws Exception { pool.parseBody(old); b.author(old.getAuthorIdent()); b.committer(old.getCommitterIdent()); b.message(old.getFullMessage()); // Use the committer name from the old commit, but update it after ticking // the clock in CommitBuilder#create(). b.updateCommitterTime = true; // Reset parents to original parents. b.noParents(); for (int i = 0; i < old.getParentCount(); i++) b.parent(old.getParent(i)); // Reset tree to original tree; resetting parents reset tree contents to the // first parent. b.tree.clear(); try (TreeWalk tw = new TreeWalk(db)) { tw.reset(old.getTree()); tw.setRecursive(true); while (tw.next()) { b.edit(new PathEdit(tw.getPathString()) { @Override public void apply(DirCacheEntry ent) { ent.setFileMode(tw.getFileMode(0)); ent.setObjectId(tw.getObjectId(0)); } }); } } return b; }
private CommitBuilder amend(RevCommit old, CommitBuilder b) throws Exception { pool.parseBody(old); b.author(old.getAuthorIdent()); b.committer(old.getCommitterIdent()); b.message(old.getFullMessage()); // Use the committer name from the old commit, but update it after ticking // the clock in CommitBuilder#create(). b.updateCommitterTime = true; // Reset parents to original parents. b.noParents(); for (int i = 0; i < old.getParentCount(); i++) b.parent(old.getParent(i)); // Reset tree to original tree; resetting parents reset tree contents to the // first parent. b.tree.clear(); try (TreeWalk tw = new TreeWalk(db)) { tw.reset(old.getTree()); tw.setRecursive(true); while (tw.next()) { b.edit(new PathEdit(tw.getPathString()) { @Override public void apply(DirCacheEntry ent) { ent.setFileMode(tw.getFileMode(0)); ent.setObjectId(tw.getObjectId(0)); } }); } } return b; }