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

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

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

Ref.isSymbolic介绍

[英]Test if this reference is a symbolic reference.

A symbolic reference does not have its own org.eclipse.jgit.lib.ObjectId value, but instead points to another Ref in the same database and always uses that other reference's value as its own.
[中]测试此引用是否为符号引用。
符号引用没有自己的组织。日食jgit。lib。ObjectId值,但指向同一数据库中的另一个引用,并始终使用该另一个引用的值作为自己的值。

代码示例

代码示例来源:origin: jphp-group/jphp

public static ArrayMemory valueOf(Ref ref) {
  ArrayMemory memory = new ArrayMemory();
  memory.refOfIndex("name").assign(ref.getName());
  memory.refOfIndex("peeled").assign(ref.isPeeled());
  memory.refOfIndex("symbolic").assign(ref.isSymbolic());
  memory.refOfIndex("objectId").assign(valueOf(ref.getObjectId()));
  memory.refOfIndex("storage").assign(valueOf(ref.getStorage()));
  return memory;
}

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

private static boolean equals(Ref r1, Ref r2) {
  if (r1 == null || r2 == null) {
    return false;
  }
  if (r1.isSymbolic()) {
    return r2.isSymbolic() && r1.getTarget().getName()
        .equals(r2.getTarget().getName());
  }
  return !r2.isSymbolic()
      && Objects.equals(r1.getObjectId(), r2.getObjectId());
}

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

private static void append(StringBuilder s, Ref r, String nullName) {
  if (r == null) {
    s.append(nullName);
  } else if (r.isSymbolic()) {
    s.append(r.getTarget().getName());
  } else {
    ObjectId id = r.getObjectId();
    if (id != null) {
      s.append(id.name());
    }
  }
}

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

/** {@inheritDoc} */
@Override
public Ref exactRef(String name) throws IOException {
  lock.lock();
  try {
    Reftable table = reader();
    Ref ref = table.exactRef(name);
    if (ref != null && ref.isSymbolic()) {
      return table.resolve(ref);
    }
    return ref;
  } finally {
    lock.unlock();
  }
}

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

private static void findSymrefs(
    final RefAdvertiser adv, final Map<String, Ref> refs) {
  Ref head = refs.get(Constants.HEAD);
  if (head != null && head.isSymbolic()) {
    adv.addSymref(Constants.HEAD, head.getLeaf().getName());
  }
}

代码示例来源: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

/** {@inheritDoc} */
@Override
@NonNull
public Ref getLeaf() {
  Ref dst = getTarget();
  while (dst.isSymbolic())
    dst = dst.getTarget();
  return dst;
}

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

private static void format(StringBuilder s, @Nullable Ref r, String n) {
    if (r == null) {
      s.append(n);
    } else if (r.isSymbolic()) {
      s.append(r.getTarget().getName());
    } else {
      ObjectId id = r.getObjectId();
      if (id != null) {
        s.append(id.abbreviate(8).name());
      }
    }
  }
}

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

private String getShortBranchName(Ref headRef) {
  if (headRef.isSymbolic()) {
    return Repository.shortenRefName(headRef.getTarget().getName());
  }
  // Detached HEAD. Every non-symbolic ref in the ref database has an
  // object id, so this cannot be null.
  ObjectId id = headRef.getObjectId();
  if (id == null) {
    throw new NullPointerException();
  }
  return id.getName();
}

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

private static Ref recreate(Ref old, Ref leaf) {
  if (old.isSymbolic()) {
    Ref dst = recreate(old.getTarget(), leaf);
    return new SymbolicRef(old.getName(), dst);
  }
  return leaf;
}

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

static Ref recreate(Ref old, Ref leaf) {
  if (old.isSymbolic()) {
    Ref dst = recreate(old.getTarget(), leaf);
    return new SymbolicRef(old.getName(), dst);
  }
  return leaf;
}

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

private static String getHeadName(Ref head) {
  String headName;
  if (head.isSymbolic()) {
    headName = head.getTarget().getName();
  } else {
    ObjectId headId = head.getObjectId();
    // the callers are checking this already
    assert headId != null;
    headName = headId.getName();
  }
  return headName;
}

代码示例来源: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 static Ref recreate(Ref old, ObjectIdRef leaf) {
  if (old.isSymbolic()) {
    Ref dst = recreate(old.getTarget(), leaf);
    return new SymbolicRef(old.getName(), dst);
  }
  return leaf;
}

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

/** {@inheritDoc} */
@Override
public RefUpdate newUpdate(String refName, boolean detach)
    throws IOException {
  boolean detachingSymbolicRef = false;
  Ref ref = exactRef(refName);
  if (ref == null)
    ref = new ObjectIdRef.Unpeeled(NEW, refName, null);
  else
    detachingSymbolicRef = detach && ref.isSymbolic();
  DfsRefUpdate update = new DfsRefUpdate(this, ref);
  if (detachingSymbolicRef)
    update.setDetachingSymbolicRef();
  return update;
}

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

/** {@inheritDoc} */
@Override
protected boolean tryLock(boolean deref) throws IOException {
  dstRef = getRef();
  if (deref)
    dstRef = dstRef.getLeaf();
  if (dstRef.isSymbolic())
    setOldObjectId(null);
  else
    setOldObjectId(dstRef.getObjectId());
  return true;
}

代码示例来源: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: org.eclipse.jgit/org.eclipse.jgit

private Ref resolve(ObjectReader reader, Ref ref, int depth)
    throws IOException {
  if (ref.isSymbolic() && depth < MAX_SYMBOLIC_REF_DEPTH) {
    Ref r = readRef(reader, ref.getTarget().getName());
    if (r == null) {
      return ref;
    }
    Ref dst = resolve(reader, r, depth + 1);
    return new SymbolicRef(ref.getName(), dst);
  }
  return ref;
}

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

private Ref resolve(Ref ref, int depth, RefList<Ref> loose)
    throws IOException {
  if (!ref.isSymbolic())
    return ref;
  Ref dst = ref.getTarget();
  if (MAX_SYMBOLIC_REF_DEPTH <= depth)
    return null; // claim it doesn't exist
  dst = loose.get(dst.getName());
  if (dst == null)
    return ref;
  dst = resolve(dst, depth + 1, loose);
  if (dst == null)
    return null;
  return new SymbolicRef(ref.getName(), dst);
}

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

private static boolean matchOld(ReceiveCommand cmd, @Nullable Ref ref) {
  if (ref == null) {
    return AnyObjectId.equals(ObjectId.zeroId(), cmd.getOldId())
        && cmd.getOldSymref() == null;
  } else if (ref.isSymbolic()) {
    return ref.getTarget().getName().equals(cmd.getOldSymref());
  }
  ObjectId id = ref.getObjectId();
  if (id == null) {
    id = ObjectId.zeroId();
  }
  return cmd.getOldId().equals(id);
}

相关文章