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

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

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

Ref.getPeeledObjectId介绍

[英]Cached value of ref^{} (the ref peeled to commit).
[中]缓存值ref^{}(ref被剥离以提交)。

代码示例

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

private static Set<ObjectId> refIdSet(Collection<Ref> refs) {
  Set<ObjectId> ids = new HashSet<>(refs.size());
  for (Ref ref : refs) {
    ObjectId id = ref.getObjectId();
    if (id != null) {
      ids.add(id);
    }
    id = ref.getPeeledObjectId();
    if (id != null) {
      ids.add(id);
    }
  }
  return ids;
}

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

@Override
  public void apply(DirCacheEntry ent) {
    ent.setFileMode(GITLINK);
    ent.setObjectId(newRef.getPeeledObjectId());
  }
}.setReplace(false));

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

/** {@inheritDoc} */
@Override
@Nullable
public ObjectId getPeeledObjectId() {
  return getLeaf().getPeeledObjectId();
}

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

private void markRefsAdvertised() {
  for (Ref r : getRefs()) {
    markAdvertised(r.getObjectId());
    if (r.getPeeledObjectId() != null)
      markAdvertised(r.getPeeledObjectId());
  }
}

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

/**
 * Get a map with all objects referenced by a peeled ref.
 *
 * @return a map with all objects referenced by a peeled ref.
 */
@NonNull
public Map<AnyObjectId, Set<Ref>> getAllRefsByPeeledObjectId() {
  Map<String, Ref> allRefs = getAllRefs();
  Map<AnyObjectId, Set<Ref>> ret = new HashMap<>(allRefs.size());
  for (Ref ref : allRefs.values()) {
    ref = peel(ref);
    AnyObjectId target = ref.getPeeledObjectId();
    if (target == null)
      target = ref.getObjectId();
    // We assume most Sets here are singletons
    Set<Ref> oset = ret.put(target, Collections.singleton(ref));
    if (oset != null) {
      // that was not the case (rare)
      if (oset.size() == 1) {
        // Was a read-only singleton, we must copy to a new Set
        oset = new HashSet<>(oset);
      }
      ret.put(target, oset);
      oset.add(ref);
    }
  }
  return ret;
}

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

/**
 * Include a single ref (a name/object pair) in the bundle.
 * <p>
 * This is a utility function for:
 * <code>include(r.getName(), r.getObjectId())</code>.
 *
 * @param r
 *            the ref to include.
 */
public void include(Ref r) {
  include(r.getName(), r.getObjectId());
  if (r.getPeeledObjectId() != null)
    tagTargets.add(r.getPeeledObjectId());
  else if (r.getObjectId() != null
      && r.getName().startsWith(Constants.R_HEADS))
    tagTargets.add(r.getObjectId());
}

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

private ObjectId getObjectIdFromRef(Ref r) throws JGitInternalException {
  try {
    ObjectId key = repo.getRefDatabase().peel(r).getPeeledObjectId();
    if (key == null) {
      key = r.getObjectId();
    }
    return key;
  } catch (IOException e) {
    throw new JGitInternalException(e.getMessage(), e);
  }
}

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

@Override
int valueType() {
  if (ref.isSymbolic()) {
    return VALUE_SYMREF;
  } else if (ref.getStorage() == NEW && ref.getObjectId() == null) {
    return VALUE_NONE;
  } else if (ref.getPeeledObjectId() != null) {
    return VALUE_2ID;
  } else {
    return VALUE_1ID;
  }
}

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

if (ref.getObjectId() != null)
  r.add(ref.getObjectId());
if (ref.getPeeledObjectId() != null)
  r.add(ref.getPeeledObjectId());

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

throw outOfOrderAdvertisement(name);
if (prior.getPeeledObjectId() != null)
  throw duplicateAdvertisement(name + "^{}"); //$NON-NLS-1$

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

private void indexRef(Ref ref, long blockPos) {
  if (indexObjects && !ref.isSymbolic()) {
    indexId(ref.getObjectId(), blockPos);
    indexId(ref.getPeeledObjectId(), blockPos);
  }
}

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

private Collection<Ref> expandAutoFollowTags() throws TransportException {
  final Collection<Ref> additionalTags = new ArrayList<>();
  final Map<String, Ref> haveRefs = localRefs();
  for (Ref r : conn.getRefs()) {
    if (!isTag(r))
      continue;
    Ref local = haveRefs.get(r.getName());
    if (local != null)
      // We already have a tag with this name, don't fetch it (even if
      // the local is different).
      continue;
    ObjectId obj = r.getPeeledObjectId();
    if (obj == null)
      obj = r.getObjectId();
    if (askFor.containsKey(obj) || transport.local.hasObject(obj))
      wantTag(r);
    else
      additionalTags.add(r);
  }
  return additionalTags;
}

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

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())));
  }
}

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

public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      try (Git git = new Git(repository)) {
        List<Ref> call = git.tagList().call();
        for (Ref ref : call) {
          System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName());

          // fetch all commits for this tag
          LogCommand log = git.log();

          Ref peeledRef = repository.getRefDatabase().peel(ref);
          if(peeledRef.getPeeledObjectId() != null) {
            log.add(peeledRef.getPeeledObjectId());
          } else {
            log.add(ref.getObjectId());
          }

          Iterable<RevCommit> logs = log.call();
          for (RevCommit rev : logs) {
            System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */);
          }
        }
      }
    }
  }
}

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

public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
      try (Git git = new Git(repository)) {
        List<Ref> call = git.tagList().call();
        for (Ref ref : call) {
          System.out.println("Tag: " + ref + " " + ref.getName() + " " + ref.getObjectId().getName());

          // fetch all commits for this tag
          LogCommand log = git.log();

          Ref peeledRef = repository.getRefDatabase().peel(ref);
          if(peeledRef.getPeeledObjectId() != null) {
            log.add(peeledRef.getPeeledObjectId());
          } else {
            log.add(ref.getObjectId());
          }

          Iterable<RevCommit> logs = log.call();
          for (RevCommit rev : logs) {
            System.out.println("Commit: " + rev /* + ", name: " + rev.getName() + ", id: " + rev.getId().getName() */);
          }
        }
      }
    }
  }
}

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

ObjectId id2 = ref.getPeeledObjectId();
if (!ref.isPeeled()) {
  throw new IOException(JGitText.get().peeledRefIsRequired);

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

private Ref asNew(Ref src) {
    String name = destination.getName();
    if (src.isSymbolic()) {
      return new SymbolicRef(name, src.getTarget());
    }

    ObjectId peeled = src.getPeeledObjectId();
    if (peeled != null) {
      return new ObjectIdRef.PeeledTag(
          src.getStorage(),
          name,
          src.getObjectId(),
          peeled);
    }

    return new ObjectIdRef.PeeledNonTag(
        src.getStorage(),
        name,
        src.getObjectId());
  }
}

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

ref = getRepository().getRefDatabase().peel(ref);
ObjectId objectId = ref.getPeeledObjectId();
if (objectId == null)
  objectId = ref.getObjectId();

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

/**
 * Make sure a ref is peeled and has the Storage PACKED. If the given ref
 * has this attributes simply return it. Otherwise create a new peeled
 * {@link ObjectIdRef} where Storage is set to PACKED.
 *
 * @param f
 * @return a ref for Storage PACKED having the same name, id, peeledId as f
 * @throws MissingObjectException
 * @throws IOException
 */
private Ref peeledPackedRef(Ref f)
    throws MissingObjectException, IOException {
  if (f.getStorage().isPacked() && f.isPeeled()) {
    return f;
  }
  if (!f.isPeeled()) {
    f = peel(f);
  }
  ObjectId peeledObjectId = f.getPeeledObjectId();
  if (peeledObjectId != null) {
    return new ObjectIdRef.PeeledTag(PACKED, f.getName(),
        f.getObjectId(), peeledObjectId);
  } else {
    return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
        f.getObjectId());
  }
}

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

private void markReachable(Set<ObjectId> have, int maxTime)
    throws IOException {
  for (Ref r : local.getRefDatabase().getRefs()) {
    ObjectId id = r.getPeeledObjectId();
    if (id == null)
      id = r.getObjectId();

相关文章