本文整理了Java中org.eclipse.jgit.lib.Ref.getTarget
方法的一些代码示例,展示了Ref.getTarget
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.getTarget
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Ref
类名称:Ref
方法名:getTarget
[英]Get the reference this reference points to, or this.
If #isSymbolic() is true this method returns the reference it directly names, which might not be the leaf reference, but could be another symbolic reference.
If this is a leaf level reference that contains its own ObjectId,this method returns this.
[中]获取这个参考点的参考,或者这个。
如果#isSymbolic()为true,此方法将返回它直接命名的引用,该引用可能不是叶引用,但可能是另一个符号引用。
如果这是一个包含自己的ObjectId的叶级引用,则此方法将返回它。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String calculateOurName(Ref headRef) {
if (ourCommitName != null)
return ourCommitName;
String targetRefName = headRef.getTarget().getName();
String headName = Repository.shortenRefName(targetRefName);
return headName;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String calculateOurName(Ref headRef) {
if (ourCommitName != null)
return ourCommitName;
String targetRefName = headRef.getTarget().getName();
String headName = Repository.shortenRefName(targetRefName);
return headName;
}
代码示例来源: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
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
/** {@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 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 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 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
@Override
int valueSize() {
int n = computeVarintSize(updateIndexDelta);
switch (valueType()) {
case VALUE_NONE:
return n;
case VALUE_1ID:
return n + OBJECT_ID_LENGTH;
case VALUE_2ID:
return n + 2 * OBJECT_ID_LENGTH;
case VALUE_SYMREF:
if (ref.isSymbolic()) {
int nameLen = nameUtf8(ref.getTarget()).length;
return n + computeVarintSize(nameLen) + nameLen;
}
}
throw new IllegalStateException();
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Whether the {@code Constants#HEAD} reference needs to be linked to the
* new destination name.
*
* @return true if the {@code Constants#HEAD} reference needs to be linked
* to the new destination name.
* @throws java.io.IOException
* the current value of {@code HEAD} cannot be read.
*/
protected boolean needToUpdateHEAD() throws IOException {
Ref head = source.getRefDatabase().getRef(Constants.HEAD);
if (head != null && head.isSymbolic()) {
head = head.getTarget();
return head.getName().equals(source.getName());
}
return false;
}
}
代码示例来源: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 Ref resolve(Ref ref, int depth, RefList<Ref> refs)
throws IOException {
if (!ref.isSymbolic()) {
return ref;
} else if (MAX_SYMBOLIC_REF_DEPTH <= depth) {
return null;
}
Ref r = refs.get(ref.getTarget().getName());
if (r == null) {
return ref;
}
Ref dst = resolve(r, depth + 1, refs);
if (dst == null) {
return null;
}
return new SymbolicRef(ref.getName(), dst);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private Ref resolve(Ref ref, int depth) 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 = exactRef(dst.getName());
if (dst == null) {
return ref;
}
dst = resolve(dst, depth + 1);
if (dst == null) {
return null; // claim it doesn't exist
}
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);
}
代码示例来源: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
private static boolean check(@Nullable DirCacheEntry cur,
@Nullable Ref exp) {
if (cur == null) {
// Does not exist, ok if oldRef does not exist.
return exp == null;
} else if (exp == null) {
// Expected to not exist, but currently exists, fail.
return false;
}
if (exp.isSymbolic()) {
String dst = exp.getTarget().getName();
return cur.getRawMode() == TYPE_SYMLINK
&& cur.getObjectId().equals(symref(dst));
}
return cur.getRawMode() == TYPE_GITLINK
&& cur.getObjectId().equals(exp.getObjectId());
}
内容来源于网络,如有侵权,请联系作者删除!