protected @Override java.util.Optional<Ref> _call() { Ref head = command(RefParse.class).setName(branchName).call().orNull(); if (head != null && Ref.HEAD.equals(branchName) && (head instanceof SymRef)) { head = head.peel(); } return Optional.ofNullable(head); }
private Ref toLocal(Ref remoteRef) { Optional<String> localName = remote.mapToRemote(remoteRef.getName()); Preconditions.checkArgument(localName.isPresent(), "Can't map %s to local ref using %s", remoteRef.getName(), remote.getFetchSpec()); Ref localRef; if (remoteRef instanceof SymRef) { Ref target = toLocal(remoteRef.peel()); localRef = new SymRef(localName.get(), target); } else { localRef = new Ref(localName.get(), remoteRef.getObjectId()); } return localRef; }
private Ref toRemote(Ref localRef) { Optional<String> remoteName = remote.mapToLocal(localRef.getName()); Preconditions.checkArgument(remoteName.isPresent(), "Can't map %s to remote ref using %s", localRef.getName(), remote.getFetchSpec()); Ref remoteRef; if (localRef instanceof SymRef) { Ref target = toRemote(localRef.peel()); remoteRef = new SymRef(remoteName.get(), target); } else { remoteRef = new Ref(remoteName.get(), localRef.getObjectId()); } return remoteRef; }
private static Set<ObjectId> veifyRepositoryContents(Repository repo, Map<String, Ref> allRefs) { Set<ObjectId> allIds = Sets.newConcurrentHashSet(); for (Ref ref : allRefs.values()) { if (ref instanceof SymRef) { Ref target = ref.peel(); assertTrue(format("symref points to a non existent ref: %s", ref), allRefs.containsKey(target.getName())); } else { Stack<String> pathToObject = new Stack<>(); pathToObject.push(ref.getName()); verifyAllReachableContents(repo, ref.getObjectId(), pathToObject, allIds); pathToObject.pop(); } } return allIds; }
.call().orNull(); if (currRemoteHead instanceof SymRef) { currentBranch = currRemoteHead.peel().localName();
/** * Verifies that all the reachable objects from all the refs in the repo exist in the repo's * database */ public static Set<ObjectId> verifyRepositoryContents(Repository repo) { Map<String, Ref> allRefs = Maps.uniqueIndex(repo.command(ForEachRef.class).call(), (r) -> r.getName()); allRefs = Maps.filterKeys(allRefs, (k) -> !k.equals(Ref.STAGE_HEAD) && !k.equals(Ref.WORK_HEAD)); Set<ObjectId> allIds = Sets.newConcurrentHashSet(); for (Ref ref : allRefs.values()) { if (ref instanceof SymRef) { Ref target = ref.peel(); assertTrue(format("symref points to a non existent ref: %s", ref), allRefs.containsKey(target.getName())); } else { Stack<String> pathToObject = new Stack<>(); pathToObject.push(ref.getName()); verifyAllReachableContents(repo, ref.getObjectId(), pathToObject, allIds); pathToObject.pop(); } } return allIds; }
Ref rhead = remoteHeadRef.get(); if (rhead instanceof SymRef) { currentBranch = rhead.peel().localName(); } else {
checkArgument(headRef.isPresent() && headRef.get() instanceof SymRef, "Cannot rename detached HEAD."); oldBranch = command(RefParse.class).setName(headRef.get().peel().localName()).call(); } else { oldBranch = command(RefParse.class).setName(oldBranchName).call();
checkState(currHead instanceof SymRef, "Can't revert from detached HEAD"); checkState(!currHead.getObjectId().isNull(), "HEAD has no history."); currentBranch = currHead.peel().getName(); revertHead = currHead.getObjectId();
String refName = target.peel().getName(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(refName).call(); checkoutResult.setNewRef(targetRef.get());
String refName = target.peel().getName(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(refName).call(); result.setNewRef(targetRef.get());
throw new IllegalStateException(); Ref want = cr.getNewRef().peel();
public @Test void prepareAndManuallyResolveAllConflicts() { createConflicts(TestData.point1, TestData.line1, TestData.poly1); PRStatus result = prepare(); assertEquals(3, result.getNumConflicts()); final UUID transactionId = request.getTransactionId(); origin.resumeTransaction(transactionId); assertEquals(request.getTargetBranch(), origin.getRef("HEAD").peel().localName()); //@formatter:off SimpleFeature c1 = TestData.clone(TestData.point1); c1.setAttribute("sp", "manually set"); SimpleFeature c2 = TestData.clone(TestData.line1); c2.setAttribute("sp", "manually set"); SimpleFeature c3 = TestData.clone(TestData.poly1); c3.setAttribute("sp", "manually set"); //@formatter:on Context context = clone.checkout("issuerBranch").getContext(); try { PullResult pres = context.command(PullOp.class).addRefSpec("master").call(); fail("Expected MergeConflictsException , got " + pres); } catch (MergeConflictsException e) { assertEquals(3, e.getReport().getConflicts()); clone.insert(c1, c2, c3).add().commit("manual conflict fix"); } result = prepare(); assertTrue(result.getMergeCommit().isPresent()); assertTrue(result.getReport().isPresent()); GeogigTransaction prtx = getTransaction(); Optional<Ref> mergeRef = request.resolveMergeRef(prtx); assertTrue(mergeRef.isPresent()); assertEquals(result.getMergeCommit().get(), mergeRef.get().getObjectId()); }
assertEquals(request.getTargetBranch(), origin.getRef("HEAD").peel().localName());
assertEquals(request.getTargetBranch(), origin.getRef("HEAD").peel().localName());