本文整理了Java中org.eclipse.jgit.lib.Ref.getStorage
方法的一些代码示例,展示了Ref.getStorage
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.getStorage
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Ref
类名称:Ref
方法名:getStorage
[英]How was this ref obtained?
The current storage model of a Ref may influence how the ref must be updated or deleted from the repository.
[中]这个裁判是怎么得到的?
Ref的当前存储模型可能会影响必须从存储库中更新或删除Ref的方式。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private Storage loose(Ref r) {
if (r != null && r.getStorage() == Storage.PACKED) {
return Storage.LOOSE_PACKED;
}
return Storage.LOOSE;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private Storage loose(Ref r) {
if (r != null && r.getStorage() == Storage.PACKED)
return Storage.LOOSE_PACKED;
return Storage.LOOSE;
}
代码示例来源: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
/** {@inheritDoc} */
@Override
protected Result doDelete(Result status) throws IOException {
if (getRef().getStorage() != Ref.Storage.NEW)
database.delete(this);
return status;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Whether the current reference was deleted.
*
* @return {@code true} if the current reference was deleted.
*/
public boolean wasDeleted() {
Ref r = getRef();
return r.getStorage() == Ref.Storage.NEW && r.getObjectId() == null;
}
代码示例来源: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
boolean peeled = false;
for (Ref r : refs) {
if (r.getStorage().isPacked() && r.isPeeled()) {
peeled = true;
break;
if (r.getStorage() != Ref.Storage.PACKED)
continue;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
protected Result doLink(String target) throws IOException {
Ref dst = new ObjectIdRef.Unpeeled(NEW, target, null);
SymbolicRef n = new SymbolicRef(getName(), dst);
Result desiredResult = getRef().getStorage() == NEW
? Result.NEW
: Result.FORCED;
return run(n, desiredResult);
}
代码示例来源: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 void deleteCommand(RemoteRefUpdate u) {
final Ref r = newRefs.remove(u.getRemoteName());
if (r == null) {
// Already gone.
//
u.setStatus(Status.OK);
return;
}
if (r.getStorage().isPacked())
packedRefUpdates.add(u);
if (r.getStorage().isLoose()) {
try {
dest.deleteRef(u.getRemoteName());
u.setStatus(Status.OK);
} catch (IOException e) {
u.setStatus(Status.REJECTED_OTHER_REASON);
u.setMessage(e.getMessage());
}
}
try {
dest.deleteRefLog(u.getRemoteName());
} catch (IOException e) {
u.setStatus(Status.REJECTED_OTHER_REASON);
u.setMessage(e.getMessage());
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
Storage storage = r.getStorage();
if (storage == Storage.LOOSE || storage == Storage.LOOSE_PACKED)
ret.numberOfLooseRefs++;
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private ObjectIdRef doPeel(Ref leaf) throws MissingObjectException,
IOException {
try (RevWalk rw = new RevWalk(getRepository())) {
RevObject obj = rw.parseAny(leaf.getObjectId());
if (obj instanceof RevTag) {
return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
.getName(), leaf.getObjectId(), rw.peel(obj).copy());
} else {
return new ObjectIdRef.PeeledNonTag(leaf.getStorage(), leaf
.getName(), leaf.getObjectId());
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Packs all non-symbolic, loose refs into packed-refs.
*
* @throws java.io.IOException
*/
public void packRefs() throws IOException {
Collection<Ref> refs = repo.getRefDatabase()
.getRefsByPrefix(Constants.R_REFS);
List<String> refsToBePacked = new ArrayList<>(refs.size());
pm.beginTask(JGitText.get().packRefs, refs.size());
try {
for (Ref ref : refs) {
checkCancelled();
if (!ref.isSymbolic() && ref.getStorage().isLoose())
refsToBePacked.add(ref.getName());
pm.update(1);
}
((RefDirectory) repo.getRefDatabase()).pack(refsToBePacked);
} finally {
pm.endTask();
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
Ref doPeel(Ref leaf) throws MissingObjectException,
IOException {
try (RevWalk rw = new RevWalk(repository)) {
RevObject obj = rw.parseAny(leaf.getObjectId());
if (obj instanceof RevTag) {
return new ObjectIdRef.PeeledTag(
leaf.getStorage(),
leaf.getName(),
leaf.getObjectId(),
rw.peel(obj).copy());
} else {
return new ObjectIdRef.PeeledNonTag(
leaf.getStorage(),
leaf.getName(),
leaf.getObjectId());
}
}
}
代码示例来源: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
/** {@inheritDoc} */
@Override
protected Result doLink(String target) throws IOException {
final SymbolicRef newRef = new SymbolicRef(
dstRef.getName(),
new ObjectIdRef.Unpeeled(
Storage.NEW,
target,
null));
if (getRefDatabase().compareAndPut(dstRef, newRef)) {
getRefDatabase().stored(newRef);
if (dstRef.getStorage() == Ref.Storage.NEW)
return Result.NEW;
return Result.FORCED;
}
return Result.LOCK_FAILURE;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (dst.getStorage().isLoose()) {
update.unlock();
delete(fileFor(name), levels);
代码示例来源: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
/** {@inheritDoc} */
@Override
protected Result doLink(String target) throws IOException {
WriteConfig wc = database.getRepository().getConfig()
.get(WriteConfig.KEY);
lock.setFSync(wc.getFSyncRefFiles());
lock.setNeedStatInformation(true);
lock.write(encode(RefDirectory.SYMREF + target + '\n'));
String msg = getRefLogMessage();
if (msg != null)
database.log(isForceRefLog(), this, msg, false);
if (!lock.commit())
return Result.LOCK_FAILURE;
database.storedSymbolicRef(this, lock.getCommitSnapshot(), target);
if (getRef().getStorage() == Ref.Storage.NEW)
return Result.NEW;
return Result.FORCED;
}
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
@Override
protected Result doLink(String target) throws IOException {
Ref dst = new ObjectIdRef.Unpeeled(NEW, target, null);
SymbolicRef n = new SymbolicRef(getName(), dst);
Result desiredResult = getRef().getStorage() == NEW
? Result.NEW
: Result.FORCED;
return run(n, desiredResult);
}
内容来源于网络,如有侵权,请联系作者删除!