/** * @return the non-symbolic {@link Ref} this symbolic reference points to. */ public @Override Ref peel() { return new Ref(target, getObjectId()); }
@Override public String toString() { return String.format("%s -> [%s -> %s]", getName(), target, getObjectId()); }
@Override public String toString() { return String.format("SymRef[%s -> Ref[%s -> %s]]", getName(), target, getObjectId()); }
/** * @return the non-symbolic {@link Ref} this symbolic reference points to. */ public @Override Ref peel() { return new Ref(target, getObjectId()); }
private Ref toLocal(Ref localRemoteRef) { final Remote remote = this.remote; if (localRemoteRef.namespace().equals(Ref.TAGS_PREFIX)) { return localRemoteRef; } final String localName = localRemoteRef.localName(); final String remoteNamespace = localRemoteRef.namespace(); final String expectedRemotePrefix = Ref.REMOTES_PREFIX + remote.getName() + "/"; Preconditions.checkArgument(remoteNamespace.equals(expectedRemotePrefix)); final String localPrefix = Ref.HEAD.equals(localName) ? "" : Ref.HEADS_PREFIX; final String localRefName = localPrefix + localName; Ref ref = null; if (localRemoteRef instanceof SymRef) { SymRef sr = (SymRef) localRemoteRef; Ref localTarget = toLocal(new Ref(sr.getTarget(), sr.getObjectId())); ref = new SymRef(localRefName, localTarget); } else { ref = new Ref(localRefName, localRemoteRef.getObjectId()); } return ref; }
private Ref toRemote(Ref localRef) { if (localRef.namespace().equals(Ref.TAGS_PREFIX)) { return localRef; } checkArgument(!localRef.getName().startsWith(Ref.REMOTES_PREFIX), "ref is already in a remotes namespace: %s", localRef); final String remoteNamespace = Ref.REMOTES_PREFIX + remote.getName() + "/"; final String remoteRefName = remoteNamespace + localRef.localName(); Ref remoteRef; if (localRef instanceof SymRef) { SymRef sr = (SymRef) localRef; String localtarget = sr.getTarget(); Ref remoteTarget = toRemote(new Ref(localtarget, sr.getObjectId())); remoteRef = new SymRef(remoteRefName, remoteTarget); } else { remoteRef = new Ref(remoteRefName, localRef.getObjectId()); } return remoteRef; }
"Can't revert from detached HEAD"); final SymRef headRef = (SymRef) currHead.get(); Preconditions.checkState(!headRef.getObjectId().equals(ObjectId.NULL), "HEAD has no history."); currentBranch = headRef.getTarget();
final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call(); SymRef headRef = (SymRef) currHead.get(); RevCommit headCommit = repository().getCommit(headRef.getObjectId()); command(UpdateRef.class).setName(Ref.MERGE_HEAD).setNewValue(commits.get(0)).call();
currentBranch = headRef.getTarget(); if (ObjectId.NULL.equals(headRef.getObjectId())) { final RevCommit headCommit = repository.getCommit(headRef.getObjectId()); final RevCommit targetCommit = repository.getCommit(upstream.get());
final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call(); SymRef headRef = (SymRef) currHead.get(); RevCommit headCommit = repository().getCommit(headRef.getObjectId()); command(UpdateRef.class).setName(Ref.MERGE_HEAD).setNewValue(commits.get(0)).call();
currentBranch = headRef.getTarget(); if (ObjectId.NULL.equals(headRef.getObjectId())) { final RevCommit headCommit = repository.getCommit(headRef.getObjectId()); final RevCommit targetCommit = repository.getCommit(upstream.get());
RevCommit commitToApply = repository.getCommit(commit); ObjectId headId = headRef.getObjectId();
RevCommit commitToApply = repository.getCommit(commit); ObjectId headId = headRef.getObjectId();