/** * 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); }
/** {@inheritDoc} */ @Override public void finish() { if (!edits.isEmpty()) { applyEdits(); replace(); } }
final int cnt = Math.min(eIdx, maxIdx) - lastIdx; if (cnt > 0) fastKeep(lastIdx, cnt); ? deleteOverlappingSubtree(ent, eIdx) : eIdx; fastAdd(ent); } else { final DirCacheEntry ent = cache.getEntry(i); e.apply(ent); fastAdd(ent); fastKeep(lastIdx, cnt);
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()))); } }
ed.finish(); return true; } catch (DirCacheNameConflictException e) {
editor.add(new DirCacheEditor.PathEdit(new DirCacheEntry(key)) { @Override public void apply(final DirCacheEntry ent) { editor.finish(); } catch (Exception e) { throw new RuntimeException(e); editor.getDirCache().clear(); return Optional.empty();
edit.commit(); } catch (IOException e) {
ed.add(new DeletePath(path)); cleanupPeeledRef(ed, oldRef); return; ed.add(new PathEdit(path) { @Override public void apply(DirCacheEntry ent) { ed.add(new PathEdit(path) { @Override public void apply(DirCacheEntry ent) { ed.add(new PathEdit(peeledPath(newRef.getName())) { @Override public void apply(DirCacheEntry ent) {
public static void deleteDirectory(@Nonnull String path, @Nonnull DirCache cache) { DirCacheEditor editor = cache.editor(); deleteDirectory(path, editor); editor.finish(); }
final int cnt = Math.min(eIdx, maxIdx) - lastIdx; if (cnt > 0) fastKeep(lastIdx, cnt); ? deleteOverlappingSubtree(ent, eIdx) : eIdx; fastAdd(ent); } else { final DirCacheEntry ent = cache.getEntry(i); e.apply(ent); fastAdd(ent); fastKeep(lastIdx, cnt);
public void finish() { if (!edits.isEmpty()) { applyEdits(); replace(); } }
void addToTemporaryInCoreIndex(final DirCacheEditor editor, final DirCacheEntry dcEntry, final ObjectId objectId, final FileMode fileMode) { editor.add(new DirCacheEditor.PathEdit(dcEntry) { @Override public void apply(final DirCacheEntry ent) { ent.setObjectId(objectId); ent.setFileMode(fileMode); } }); } }
public static void deleteFile(@Nonnull String path, @Nonnull DirCache cache) { DirCacheEditor editor = cache.editor(); deleteFile(path, editor); editor.finish(); }
private void checkoutPathsFromCommit(TreeWalk treeWalk, DirCache dc, RevCommit commit) throws IOException { treeWalk.addTree(commit.getTree()); final ObjectReader r = treeWalk.getObjectReader(); DirCacheEditor editor = dc.editor(); while (treeWalk.next()) { final ObjectId blobId = treeWalk.getObjectId(0); final FileMode mode = treeWalk.getFileMode(0); final EolStreamType eolStreamType = treeWalk .getEolStreamType(CHECKOUT_OP); final String filterCommand = treeWalk .getFilterCommand(Constants.ATTR_FILTER_TYPE_SMUDGE); final String path = treeWalk.getPathString(); editor.add(new PathEdit(path) { @Override public void apply(DirCacheEntry ent) { ent.setObjectId(blobId); ent.setFileMode(mode); checkoutPath(ent, r, new CheckoutMetadata(eolStreamType, filterCommand)); actuallyModifiedPaths.add(path); } }); } editor.commit(); }
final int cnt = Math.min(eIdx, maxIdx) - lastIdx; if (cnt > 0) fastKeep(lastIdx, cnt); ? deleteOverlappingSubtree(ent, eIdx) : eIdx; fastAdd(ent); } else { final DirCacheEntry ent = cache.getEntry(i); e.apply(ent); fastAdd(ent); fastKeep(lastIdx, cnt);
/** {@inheritDoc} */ @Override public void finish() { if (!edits.isEmpty()) { applyEdits(); replace(); } }
/** * Create a new editor to recreate this cache. * <p> * Callers should add commands to the editor, then use * {@link DirCacheEditor#finish()} to update this instance. * * @return a new builder instance for this cache. */ public DirCacheEditor editor() { return new DirCacheEditor(this, entryCnt + 16); }