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

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

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

Repository.lockDirCache介绍

[英]Create a new in-core index representation, lock it, and read from disk.

The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
[中]创建一个新的核心索引表示,锁定它,然后从磁盘读取。
新索引将被锁定,然后在返回给调用方之前读取。读取失败被报告为异常,因此阻止该方法返回部分填充的索引。

代码示例

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

/** {@inheritDoc} */
@Override
protected boolean mergeImpl() throws IOException {
  if (implicitDirCache) {
    dircache = nonNullRepo().lockDirCache();
  }
  if (!inCore) {
    checkoutMetadata = new HashMap<>();
  }
  try {
    return mergeTrees(mergeBase(), sourceTrees[0], sourceTrees[1],
        false);
  } finally {
    checkoutMetadata = null;
    if (implicitDirCache) {
      dircache.unlock();
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

@Override
  public String call() throws GitAPIException {
    try {
      DirCache index = repo.lockDirCache();
      DirCacheEntry entry = index.getEntry(fileName);
      if (entry != null) {
        entry.setAssumeValid(assumeUnchanged);
        index.write();
        index.commit();
        return entry.getPathString();
      }
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
    return null;
  }
}

代码示例来源:origin: centic9/jgit-cookbook

@Override
  public String call() throws GitAPIException {
    try {
      DirCache index = repo.lockDirCache();
      DirCacheEntry entry = index.getEntry(fileName);
      if (entry != null) {
        entry.setAssumeValid(assumeUnchanged);
        index.write();
        index.commit();
        return entry.getPathString();
      }
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
    return null;
  }
}

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

private void checkoutIndex(ObjectId commitTree) throws IOException,
    GitAPIException {
  DirCache dc = repo.lockDirCache();
  try {
    DirCacheCheckout checkout = new DirCacheCheckout(repo, dc,
        commitTree);
    checkout.setFailOnConflict(false);
    checkout.setProgressMonitor(monitor);
    try {
      checkout.checkout();
    } catch (org.eclipse.jgit.errors.CheckoutConflictException cce) {
      throw new CheckoutConflictException(checkout.getConflicts(),
          cce);
    }
  } finally {
    dc.unlock();
  }
}

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

dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();

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

DirCache dc = clonedRepo.lockDirCache();
DirCacheCheckout co = new DirCacheCheckout(clonedRepo, dc,
    commit.getTree());

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

private RevCommit checkoutCurrentHead() throws IOException, NoHeadException {
  ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
  if (headTree == null)
    throw new NoHeadException(
        JGitText.get().cannotRebaseWithoutCurrentHead);
  DirCache dc = repo.lockDirCache();
  try {
    DirCacheCheckout dco = new DirCacheCheckout(repo, dc, headTree);
    dco.setFailOnConflict(false);
    dco.setProgressMonitor(monitor);
    boolean needsDeleteFiles = dco.checkout();
    if (needsDeleteFiles) {
      List<String> fileList = dco.getToBeDeleted();
      for (String filePath : fileList) {
        File fileToDelete = new File(repo.getWorkTree(), filePath);
        if (repo.getFS().exists(fileToDelete))
          FileUtils.delete(fileToDelete, FileUtils.RECURSIVE
              | FileUtils.RETRY);
      }
    }
  } finally {
    dc.unlock();
  }
  try (RevWalk rw = new RevWalk(repo)) {
    RevCommit commit = rw.parseCommit(repo.resolve(Constants.HEAD));
    return commit;
  }
}

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

RefNotFoundException {
actuallyModifiedPaths = new HashSet<>();
DirCache dc = repo.lockDirCache();
try (RevWalk revWalk = new RevWalk(repo);
    TreeWalk treeWalk = new TreeWalk(repo,

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

submoduleRepo, submoduleRepo.lockDirCache(),
    commit.getTree());
co.setFailOnConflict(true);

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

DirCache dc = repo.lockDirCache();
try {
  dco = new DirCacheCheckout(repo, headTree, dc,

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

private void resetIndexForPaths(ObjectId commitTree) {
  DirCache dc = null;
  try (TreeWalk tw = new TreeWalk(repo)) {
    dc = repo.lockDirCache();
    DirCacheBuilder builder = dc.builder();

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

RevCommit head = walk.parseCommit(repo.resolve(Constants.HEAD));
  dco = new DirCacheCheckout(repo, head.getTree(),
      repo.lockDirCache(), commit.getTree());
} else {
  dco = new DirCacheCheckout(repo, repo.lockDirCache(),
      commit.getTree());

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

RevCommit head = walk.parseCommit(repo.resolve(Constants.HEAD));
DirCacheCheckout dco = new DirCacheCheckout(repo, head.getTree(),
    repo.lockDirCache(), commit.getTree());
dco.setFailOnConflict(true);
dco.setProgressMonitor(monitor);

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

try (ObjectReader reader = repo.newObjectReader()) {
  RevCommit headCommit = parseCommit(reader, head.getObjectId());
  DirCache cache = repo.lockDirCache();
  ObjectId commitId;
  try (ObjectInserter inserter = repo.newObjectInserter();

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

private void resetIndex(RevTree tree) throws IOException {
  DirCache dc = repo.lockDirCache();
  try (TreeWalk walk = new TreeWalk(repo)) {
    DirCacheBuilder builder = dc.builder();

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

private void resetIndex(ObjectId commitTree) throws IOException {
  DirCache dc = repo.lockDirCache();
  try (TreeWalk walk = new TreeWalk(repo)) {
    DirCacheBuilder builder = dc.builder();

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

DirCache dc = repo.lockDirCache();
DirCacheCheckout dco = new DirCacheCheckout(repo, headTree,
    dc, merger.getResultTreeId());

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

continue;
DirCacheCheckout dco = new DirCacheCheckout(repo,
    headCommit.getTree(), repo.lockDirCache(),
    merger.getResultTreeId());
dco.setFailOnConflict(true);

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

continue;
DirCacheCheckout dco = new DirCacheCheckout(repo,
    newHead.getTree(), repo.lockDirCache(),
    merger.getResultTreeId());
dco.setFailOnConflict(true);

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

NameConflictTreeWalk tw = new NameConflictTreeWalk(repo)) {
tw.setOperationType(OperationType.CHECKIN_OP);
dc = repo.lockDirCache();

相关文章

Repository类方法