/** * Write this reference tree. * * @param inserter * inserter to use when writing trees to the object database. * Caller is responsible for flushing the inserter before trying * to read the objects, or exposing them through a reference. * @return the top level tree. * @throws java.io.IOException * a tree could not be written. */ public ObjectId writeTree(ObjectInserter inserter) throws IOException { if (pendingBlobs != null) { for (String s : pendingBlobs.values()) { inserter.insert(OBJ_BLOB, encode(s)); } pendingBlobs = null; } return contents.writeTree(inserter); }
cb.setAuthor(pc.ident); cb.setCommitter(pc.ident); cb.setTreeId(dc.writeTree(inserter)); if (curr != null) { cb.setParentId(curr);
Optional<ObjectId> buildTree(final DirCacheEditor editor) { try { return Optional.ofNullable(editor.getDirCache().writeTree(odi)); } catch (Exception ex) { throw new RuntimeException(ex); } }
ObjectId treeId = index.writeTree(inserter);
builder.setTreeId(cache.writeTree(inserter)); builder.setMessage(MessageFormat.format(indexMessage, branch, headCommit.abbreviate(7).name(), builder.setTreeId(untrackedDirCache.writeTree(inserter)); builder.setMessage(MessageFormat.format(MSG_UNTRACKED, branch, headCommit.abbreviate(7).name(), headCommit.abbreviate(7).name(), headCommit.getShortMessage())); builder.setTreeId(cache.writeTree(inserter)); commitId = inserter.insert(builder); inserter.flush();
@Nonnull public static AnyObjectId writeTree(@Nonnull DirCache cache, @Nonnull Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { AnyObjectId tree = cache.writeTree(inserter); inserter.flush(); return tree; } }
resultTree = dircache.writeTree(getObjectInserter()); return true; } else {
@Nonnull public static ObjectId writeTree(DirCache cache, Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { ObjectId tree = cache.writeTree(inserter); inserter.flush(); return tree; } }
@Nonnull public static RevCommit createCommit(@Nonnull String message, @Nonnull DirCache cache, @Nonnull PersonIdent author, @Nonnull PersonIdent committer, @Nonnull List<AnyObjectId> parents, @Nonnull Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { AnyObjectId commitId = insertCommit(message, cache.writeTree(inserter), author, committer, parents, inserter); inserter.flush(); return CommitUtils.getCommit(commitId, repo); } }
@Nonnull public static ObjectId writeTree(DirCache cache, Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { ObjectId tree = cache.writeTree(inserter); inserter.flush(); return tree; } }
ObjectId indexTreeId = index.writeTree(odi);
/** * Write this reference tree. * * @param inserter * inserter to use when writing trees to the object database. * Caller is responsible for flushing the inserter before trying * to read the objects, or exposing them through a reference. * @return the top level tree. * @throws IOException * a tree could not be written. */ public ObjectId writeTree(ObjectInserter inserter) throws IOException { if (pendingBlobs != null) { for (String s : pendingBlobs.values()) { inserter.insert(OBJ_BLOB, encode(s)); } pendingBlobs = null; } return contents.writeTree(inserter); }
/** * Write this reference tree. * * @param inserter * inserter to use when writing trees to the object database. * Caller is responsible for flushing the inserter before trying * to read the objects, or exposing them through a reference. * @return the top level tree. * @throws java.io.IOException * a tree could not be written. */ public ObjectId writeTree(ObjectInserter inserter) throws IOException { if (pendingBlobs != null) { for (String s : pendingBlobs.values()) { inserter.insert(OBJ_BLOB, encode(s)); } pendingBlobs = null; } return contents.writeTree(inserter); }
@Nonnull public static RevCommit createCommit(String message, DirCache cache, PersonIdent author, PersonIdent committer, List<? extends AnyObjectId> parents, Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { AnyObjectId commitId = insertCommit(message, cache.writeTree(inserter), author, committer, parents, inserter); inserter.flush(); return CommitUtils.getCommit(commitId, repo); } }
@Nonnull public static RevCommit createCommit(String message, DirCache cache, PersonIdent author, PersonIdent committer, List<? extends AnyObjectId> parents, Repository repo) throws IOException { try(ObjectInserter inserter = repo.newObjectInserter()) { AnyObjectId commitId = insertCommit(message, cache.writeTree(inserter), author, committer, parents, inserter); inserter.flush(); return CommitUtils.getCommit(commitId, repo); } }
try { ObjectInserter odi = getObjectInserter(); resultTree = cache.writeTree(odi); odi.flush(); return true;
private ObjectId writeTestFilesToTree(final DirCache dc, final DirCacheEditor editor, ObjectInserter inserter, final TestFile... testFiles) throws Exception { for (TestFile data : testFiles) { writeBlob(editor, inserter, data); } editor.finish(); final ObjectId commitTreeId = dc.writeTree(inserter); return commitTreeId; }
private ObjectId writeTestFilesToTree(final DirCache dc, final DirCacheEditor editor, ObjectInserter inserter, final TestFile... testFiles) throws Exception { for (TestFile data : testFiles) { writeBlob(editor, inserter, data); } editor.finish(); final ObjectId commitTreeId = dc.writeTree(inserter); return commitTreeId; }
public ObjectId createMergeCommit(Map<SubtreeConfig, RevCommit> parentCommits, String message) throws IOException { PersonIdent latestIdent = getLatestPersonIdent(parentCommits.values()); DirCache treeDirCache = createTreeDirCache(parentCommits, message); List<? extends ObjectId> parentIds = new ArrayList<>(parentCommits.values()); try (ObjectInserter inserter = repository.newObjectInserter()) { ObjectId treeId = treeDirCache.writeTree(inserter); PersonIdent repositoryUser = new PersonIdent(repository); PersonIdent ident = new PersonIdent(repositoryUser, latestIdent.getWhen().getTime(), latestIdent.getTimeZoneOffset()); CommitBuilder commitBuilder = new CommitBuilder(); commitBuilder.setTreeId(treeId); commitBuilder.setAuthor(ident); commitBuilder.setCommitter(ident); commitBuilder.setMessage(message); commitBuilder.setParentIds(parentIds); ObjectId mergeCommit = inserter.insert(commitBuilder); inserter.flush(); return mergeCommit; } }
/** * Construct a tree from a specific listing of file entries. * * @param entries * the files to include in the tree. The collection does not need * to be sorted properly and may be empty. * @return the new, fully parsed tree specified by the entry list. * @throws Exception */ public RevTree tree(DirCacheEntry... entries) throws Exception { final DirCache dc = DirCache.newInCore(); final DirCacheBuilder b = dc.builder(); for (DirCacheEntry e : entries) { b.add(e); } b.finish(); ObjectId root; try (ObjectInserter ins = inserter) { root = dc.writeTree(ins); ins.flush(); } return pool.parseTree(root); }