org.eclipse.jgit.lib.Repository.newObjectInserter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.eclipse.jgit.lib.Repository.newObjectInserter方法的一些代码示例,展示了Repository.newObjectInserter的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.newObjectInserter方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:newObjectInserter

Repository.newObjectInserter介绍

[英]Create a new inserter to create objects in #getObjectDatabase().
[中]创建一个新的插入器,在#getObjectDatabase()中创建对象。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Create a new merge instance for a repository.
 *
 * @param local
 *            the repository this merger will read and write data on.
 */
protected Merger(Repository local) {
  if (local == null) {
    throw new NullPointerException(JGitText.get().repositoryIsRequired);
  }
  db = local;
  inserter = local.newObjectInserter();
  reader = inserter.newReader();
  walk = new RevWalk(reader);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Constructs a NoteMapMerger with custom
 * {@link org.eclipse.jgit.notes.NoteMerger} and custom
 * {@link org.eclipse.jgit.merge.MergeStrategy}.
 *
 * @param db
 *            Git repository
 * @param noteMerger
 *            note merger for merging conflicting changes on a note
 * @param nonNotesMergeStrategy
 *            merge strategy for merging non-note entries
 */
public NoteMapMerger(Repository db, NoteMerger noteMerger,
    MergeStrategy nonNotesMergeStrategy) {
  this.db = db;
  this.reader = db.newObjectReader();
  this.inserter = db.newObjectInserter();
  this.noteMerger = noteMerger;
  this.nonNotesMergeStrategy = nonNotesMergeStrategy;
  this.objectIdPrefix = new MutableObjectId();
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w) {
  Transport wt = (Transport)t;
  local = wt.local;
  objCheck = wt.getObjectChecker();
  inserter = local.newObjectInserter();
  reader = inserter.newReader();
  remotes = new ArrayList<>();
  remotes.add(w);
  unfetchedPacks = new LinkedList<>();
  packsConsidered = new HashSet<>();
  noPacksYet = new LinkedList<>();
  noPacksYet.add(w);
  noAlternatesYet = new LinkedList<>();
  noAlternatesYet.add(w);
  fetchErrors = new HashMap<>();
  packLocks = new ArrayList<>(4);
  revWalk = new RevWalk(reader);
  revWalk.setRetainBody(false);
  treeWalk = new TreeWalk(reader);
  COMPLETE = revWalk.newFlag("COMPLETE"); //$NON-NLS-1$
  IN_WORK_QUEUE = revWalk.newFlag("IN_WORK_QUEUE"); //$NON-NLS-1$
  LOCALLY_SEEN = revWalk.newFlag("LOCALLY_SEEN"); //$NON-NLS-1$
  localCommitQueue = new DateRevQueue();
  workQueue = new LinkedList<>();
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

return RefUpdate.Result.NO_CHANGE;
try (ObjectInserter inserter = db.newObjectInserter()) {
  RefUpdate.Result result = updateRef(newId);
  switch (result) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private ObjectId insertProposals(Repository git, ProposedTimestamp ts)
    throws IOException, NoOp {
  ObjectId id;
  try (ObjectInserter inserter = git.newObjectInserter()) {
    // TODO(sop) Process signed push certificates.
    if (queuedTree != null) {
      id = insertSingleProposal(git, ts, inserter);
    } else {
      id = insertMultiProposal(git, ts, inserter);
    }
    stageCommands = makeStageList(git, inserter);
    inserter.flush();
  }
  return id;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private ObjectId write() throws IOException {
  if (pending.isEmpty()) {
    return null;
  }
  if (reader == null) {
    load();
  }
  sortPending(pending);
  ObjectId curr = commit;
  DirCache dc = newDirCache();
  try (ObjectInserter inserter = db.newObjectInserter()) {
    for (PendingCert pc : pending) {
      curr = saveCert(inserter, dc, pc, curr);
    }
    inserter.flush();
    return curr;
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
void start() throws IOException {
  ObjectId id;
  try (Repository git = leader.openRepository();
      ProposedTimestamp ts = getSystem().getClock().propose();
      ObjectInserter inserter = git.newObjectInserter()) {
    id = bumpTerm(git, ts, inserter);
    inserter.flush();
    blockUntil(ts);
  }
  runAsync(id);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/** {@inheritDoc} */
@Override
protected void doFetch(final ProgressMonitor monitor,
    final Collection<Ref> want, final Set<ObjectId> have)
    throws TransportException {
  verifyPrerequisites();
  try {
    try (ObjectInserter ins = transport.local.newObjectInserter()) {
      PackParser parser = ins.newPackParser(bin);
      parser.setAllowThin(true);
      parser.setObjectChecker(transport.getObjectChecker());
      parser.setLockMessage(lockMessage);
      packLock = parser.parse(NullProgressMonitor.INSTANCE);
      ins.flush();
    }
  } catch (IOException err) {
    close();
    throw new TransportException(transport.uri, err.getMessage(), err);
  } catch (RuntimeException err) {
    close();
    throw new TransportException(transport.uri, err.getMessage(), err);
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/** {@inheritDoc} */
@Override
public Note call() throws GitAPIException {
  checkCallable();
  NoteMap map = NoteMap.newEmptyMap();
  RevCommit notesCommit = null;
  try (RevWalk walk = new RevWalk(repo);
      ObjectInserter inserter = repo.newObjectInserter()) {
    Ref ref = repo.findRef(notesRef);
    // if we have a notes ref, use it
    if (ref != null) {
      notesCommit = walk.parseCommit(ref.getObjectId());
      map = NoteMap.read(walk.getObjectReader(), notesCommit);
    }
    map.set(id, message, inserter);
    commitNoteMap(repo, notesRef, walk, map, notesCommit, inserter,
        "Notes added by 'git notes add'"); //$NON-NLS-1$
    return map.getNote(id);
  } catch (IOException e) {
    throw new JGitInternalException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/** {@inheritDoc} */
@Override
public Note call() throws GitAPIException {
  checkCallable();
  try (RevWalk walk = new RevWalk(repo);
      ObjectInserter inserter = repo.newObjectInserter()) {
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    Ref ref = repo.exactRef(notesRef);
    // if we have a notes ref, use it
    if (ref != null) {
      notesCommit = walk.parseCommit(ref.getObjectId());
      map = NoteMap.read(walk.getObjectReader(), notesCommit);
    }
    map.set(id, null, inserter);
    AddNoteCommand.commitNoteMap(repo, notesRef, walk, map, notesCommit,
        inserter,
        "Notes removed by 'git notes remove'"); //$NON-NLS-1$
    return map.getNote(id);
  } catch (IOException e) {
    throw new JGitInternalException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private void receivePack(final ProgressMonitor monitor,
    OutputStream outputStream) throws IOException {
  onReceivePack();
  InputStream input = in;
  if (sideband)
    input = new SideBandInputStream(input, monitor, getMessageWriter(),
        outputStream);
  try (ObjectInserter ins = local.newObjectInserter()) {
    PackParser parser = ins.newPackParser(input);
    parser.setAllowThin(thinPack);
    parser.setObjectChecker(transport.getObjectChecker());
    parser.setLockMessage(lockMessage);
    packLock = parser.parse(monitor);
    ins.flush();
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

try (RevWalk rw = new RevWalk(git);
    TreeWalk tw = new TreeWalk(rw.getObjectReader());
    ObjectInserter ins = git.newObjectInserter()) {
  if (AnyObjectId.equals(oldTree, ObjectId.zeroId())) {
    tw.addTree(new EmptyTreeIterator());

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

ObjectInserter inserter = repo.newObjectInserter();
try (RevWalk rw = new RevWalk(repo)) {
  Config cfg = new Config();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

resolving = new SideBandProgressMonitor(msgOut);
try (ObjectInserter ins = db.newObjectInserter()) {
  String lockMsg = "jgit receive-pack"; //$NON-NLS-1$
  if (getRefLogIdent() != null)

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

DirCache cache = repo.lockDirCache();
ObjectId commitId;
try (ObjectInserter inserter = repo.newObjectInserter();
    TreeWalk treeWalk = new TreeWalk(repo, reader)) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private boolean apply(List<Command> todo) throws IOException {
  if (!tree.apply(todo)) {
    // apply set rejection information on commands.
    return false;
  }
  Repository repo = refdb.getRepository();
  try (ObjectInserter ins = repo.newObjectInserter()) {
    CommitBuilder b = new CommitBuilder();
    b.setTreeId(tree.writeTree(ins));
    if (parentTreeId.equals(b.getTreeId())) {
      for (Command c : todo) {
        c.setResult(OK);
      }
      return true;
    }
    if (!parentCommitId.equals(ObjectId.zeroId())) {
      b.setParentId(parentCommitId);
    }
    author = getRefLogIdent();
    if (author == null) {
      author = new PersonIdent(repo);
    }
    b.setAuthor(author);
    b.setCommitter(author);
    b.setMessage(getRefLogMessage());
    newCommitId = ins.insert(b);
    ins.flush();
  }
  return true;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

try (ObjectInserter odi = repo.newObjectInserter()) {
  if (!only.isEmpty())
    index = createTemporaryIndex(headId, index, rw);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

inserter = repo.newObjectInserter();
long contentLength = fTree
    .getEntryContentLength();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

try (ObjectInserter inserter = repo.newObjectInserter()) {
  ObjectId tagId = inserter.insert(newTag);
  inserter.flush();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

boolean addAll = filepatterns.contains("."); //$NON-NLS-1$
try (ObjectInserter inserter = repo.newObjectInserter();
    NameConflictTreeWalk tw = new NameConflictTreeWalk(repo)) {
  tw.setOperationType(OperationType.CHECKIN_OP);

相关文章

Repository类方法