本文整理了Java中org.eclipse.jgit.lib.Ref.getLeaf
方法的一些代码示例,展示了Ref.getLeaf
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.getLeaf
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Ref
类名称:Ref
方法名:getLeaf
[英]Traverse target references until #isSymbolic() is false.
If #isSymbolic() is false, returns this.
If #isSymbolic() is true, this method recursively traverses #getTarget() until #isSymbolic() returns false.
This method is effectively
return isSymbolic() ? getTarget().getLeaf() : this;
[中]遍历目标引用,直到#isSymbolic()为false。
如果#isSymbolic()为false,则返回该值。
如果#isSymbolic()为true,则此方法递归遍历#getTarget(),直到#isSymbolic()返回false。
这种方法是有效的
return isSymbolic() ? getTarget().getLeaf() : this;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Add a reference to push.
*
* @param ref
* the source reference. The remote name will match.
* @return {@code this}.
*/
public PushCommand add(Ref ref) {
refSpecs.add(new RefSpec(ref.getLeaf().getName()));
return this;
}
代码示例来源: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
/**
* Get ref that HEAD points to in the current submodule's repository
*
* @return ref name, null on failures
* @throws java.io.IOException
*/
public String getHeadRef() throws IOException {
try (Repository subRepo = getRepository()) {
if (subRepo == null) {
return null;
}
Ref head = subRepo.exactRef(Constants.HEAD);
return head != null ? head.getLeaf().getName() : null;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public Ref peel(Ref ref) throws IOException {
Ref oldLeaf = ref.getLeaf();
if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) {
return ref;
}
return recreate(ref, doPeel(oldLeaf));
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (ref != null) {
if (ref.isSymbolic())
ref = ref.getLeaf();
remoteName = parent.getConfig().getString(
ConfigConstants.CONFIG_BRANCH_SECTION,
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Get branch that HEAD currently points to
*
* @param subRepo
* a {@link org.eclipse.jgit.lib.Repository} object.
* @return shortened branch name, null on failures
* @throws java.io.IOException
*/
protected String getHeadBranch(Repository subRepo) throws IOException {
Ref head = subRepo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic())
return Repository.shortenRefName(head.getLeaf().getName());
else
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
String targetName = target.getLeaf().getName();
if (!targetName.equals(Constants.R_HEADS + Constants.MASTER)) {
String targetShortName = Repository.shortenRefName(targetName);
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (head != null && head.getLeaf().getName().equals(HEAD)) {
refs.add(head);
代码示例来源: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
void stored(RefDirectoryUpdate update, FileSnapshot snapshot) {
final ObjectId target = update.getNewObjectId().copy();
final Ref leaf = update.getRef().getLeaf();
putLooseRef(new LooseUnpeeled(snapshot, leaf.getName(), target));
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public Ref peel(Ref ref) throws IOException {
final Ref leaf = ref.getLeaf();
if (leaf.isPeeled() || leaf.getObjectId() == null)
return ref;
ObjectIdRef newLeaf = doPeel(leaf);
// Try to remember this peeling in the cache, so we don't have to do
// it again in the future, but only if the reference is unchanged.
if (leaf.getStorage().isLoose()) {
RefList<LooseRef> curList = looseRefs.get();
int idx = curList.find(leaf.getName());
if (0 <= idx && curList.get(idx) == leaf) {
LooseRef asPeeled = ((LooseRef) leaf).peel(newLeaf);
RefList<LooseRef> newList = curList.set(idx, asPeeled);
looseRefs.compareAndSet(curList, newList);
}
}
return recreate(ref, newLeaf);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
try {
tip = ow.parseAny(objectId);
if (r.getLeaf().getName().startsWith(Constants.R_HEADS)
&& tip.getType() != Constants.OBJ_COMMIT) {
errors.getNonCommitHeads().add(r.getLeaf().getName());
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public Ref peel(Ref ref) throws IOException {
final Ref oldLeaf = ref.getLeaf();
if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null)
return ref;
Ref newLeaf = doPeel(oldLeaf);
RefCache cur = read();
int idx = cur.ids.find(oldLeaf.getName());
if (0 <= idx && cur.ids.get(idx) == oldLeaf) {
RefList<Ref> newList = cur.ids.set(idx, newLeaf);
cache.compareAndSet(cur, new RefCache(newList, cur));
cachePeeledState(oldLeaf, newLeaf);
}
return recreate(ref, newLeaf);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
protected boolean tryLock(boolean deref) throws IOException {
shouldDeref = deref;
Ref dst = getRef();
if (deref)
dst = dst.getLeaf();
String name = dst.getName();
lock = new LockFile(database.fileFor(name));
if (lock.lock()) {
dst = database.getRef(name);
setOldObjectId(dst != null ? dst.getObjectId() : null);
return true;
} else {
return false;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (resolved instanceof String) {
final Ref ref = findRef((String) resolved);
return ref != null ? ref.getLeaf().getObjectId() : null;
} else {
return (ObjectId) resolved;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
final String myName = detachingSymbolicRef
? getRef().getName()
: getRef().getLeaf().getName();
if (myName.startsWith(Constants.R_HEADS) && !getRepository().isBare()) {
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
void delete(RefDirectoryUpdate update) throws IOException {
Ref dst = update.getRef();
if (!update.isDetachingSymbolicRef()) {
dst = dst.getLeaf();
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
Ref head = repo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic())
refSpecs.add(new RefSpec(head.getLeaf().getName()));
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public Ref peel(Ref ref) throws IOException {
Ref i = ref.getLeaf();
ObjectId id = i.getObjectId();
if (i.isPeeled() || id == null) {
return ref;
}
try (RevWalk rw = new RevWalk(repo)) {
RevObject obj = rw.parseAny(id);
if (obj instanceof RevTag) {
ObjectId p = rw.peel(obj).copy();
i = new ObjectIdRef.PeeledTag(PACKED, i.getName(), id, p);
} else {
i = new ObjectIdRef.PeeledNonTag(PACKED, i.getName(), id);
}
}
return recreate(ref, i);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Write the given ref update to the ref's log.
*
* @param update
* a {@link org.eclipse.jgit.lib.RefUpdate}
* @param msg
* reflog message
* @param deref
* whether to dereference symbolic refs
* @return this writer
* @throws java.io.IOException
*/
public ReflogWriter log(RefUpdate update, String msg,
boolean deref) throws IOException {
ObjectId oldId = update.getOldObjectId();
ObjectId newId = update.getNewObjectId();
Ref ref = update.getRef();
PersonIdent ident = update.getRefLogIdent();
if (ident == null)
ident = new PersonIdent(refdb.getRepository());
else
ident = new PersonIdent(ident);
byte[] rec = encode(oldId, newId, ident, msg);
if (deref && ref.isSymbolic()) {
log(ref.getName(), rec);
log(ref.getLeaf().getName(), rec);
} else
log(ref.getName(), rec);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!