Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.RefUpdate.update()


  public void testDeleteLoosePackedRejected() throws IOException {
    ObjectId pid = db.resolve("refs/heads/c^");
    ObjectId oldpid = db.resolve("refs/heads/c");
    RefUpdate updateRef = db.updateRef("refs/heads/c");
    updateRef.setNewObjectId(pid);
    Result update = updateRef.update();
    assertEquals(Result.REJECTED, update);
    assertEquals(oldpid, db.resolve("refs/heads/c"));
  }

  @Test
View Full Code Here


    ObjectId rb2 = db.resolve("refs/heads/b~1");
    assertEquals(Ref.Storage.PACKED, db.getRef("refs/heads/b").getStorage());
    RefUpdate updateRef = db.updateRef("refs/heads/b");
    updateRef.setNewObjectId(rb2);
    updateRef.setForceUpdate(true);
    Result update = updateRef.update();
    assertEquals("internal check new ref is loose", Result.FORCED, update);
    assertEquals(Ref.Storage.LOOSE, db.getRef("refs/heads/b").getStorage());
    writeReflog(db, rb, "Just a message", "refs/heads/b");
    assertTrue("log on old branch", new File(db.getDirectory(),
        "logs/refs/heads/b").exists());
View Full Code Here

    ObjectId rb = db.resolve("refs/heads/b");
    writeSymref(Constants.HEAD, "refs/heads/a");
    RefUpdate updateRef = db.updateRef("refs/heads/a");
    updateRef.setNewObjectId(rb);
    updateRef.setRefLogMessage("Setup", false);
    assertEquals(Result.FAST_FORWARD, updateRef.update());
    ObjectId oldHead = db.resolve(Constants.HEAD);
    assertEquals(oldHead, rb); // assumption for this test
    writeReflog(db, rb, "Just a message", "refs/heads/a");
    assertTrue("internal check, we have a log", new File(db.getDirectory(),
        "logs/refs/heads/a").exists());
View Full Code Here

        RefUpdate refUpdate = repo
            .updateRef(head.getTarget().getName());
        refUpdate.setNewObjectId(objectId);
        refUpdate.setExpectedOldObjectId(null);
        refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
        if (refUpdate.update() != Result.NEW)
          throw new NoHeadException(
              JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
        setCallable(false);
        return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
            null, srcCommit }, MergeStatus.FAST_FORWARD,
View Full Code Here

      ConcurrentRefUpdateException {
    RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(newHeadId);
    refUpdate.setRefLogMessage(refLogMessage.toString(), false);
    refUpdate.setExpectedOldObjectId(oldHeadID);
    Result rc = refUpdate.update();
    switch (rc) {
    case NEW:
    case FAST_FORWARD:
      return;
    case REJECTED:
View Full Code Here

    writeSymref(Constants.HEAD, "refs/heads/prefix/a");
    RefUpdate updateRef = db.updateRef("refs/heads/prefix/a");
    updateRef.setNewObjectId(rb);
    updateRef.setRefLogMessage("Setup", false);
    updateRef.setForceUpdate(true);
    assertEquals(Result.FORCED, updateRef.update());
    ObjectId oldHead = db.resolve(Constants.HEAD);
    assertEquals(oldHead, rb); // assumption for this test
    writeReflog(db, rb, "Just a message", "refs/heads/prefix/a");
    assertTrue("internal check, we have a log", new File(db.getDirectory(),
        "logs/refs/heads/prefix/a").exists());
View Full Code Here

    RevCommit commit1 = git.commit().setMessage("Initial commit")
        .call();

    RefUpdate branchRefUpdate = db.updateRef(branch);
    branchRefUpdate.setNewObjectId(commit1.getId());
    branchRefUpdate.update();

    RefUpdate trackingBranchRefUpdate = db.updateRef(trackingBranch);
    trackingBranchRefUpdate.setNewObjectId(commit1.getId());
    trackingBranchRefUpdate.update();
View Full Code Here

    branchRefUpdate.setNewObjectId(commit1.getId());
    branchRefUpdate.update();

    RefUpdate trackingBranchRefUpdate = db.updateRef(trackingBranch);
    trackingBranchRefUpdate.setNewObjectId(commit1.getId());
    trackingBranchRefUpdate.update();

    final StoredConfig config = db.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, remote);
    URIish uri = new URIish(db2.getDirectory().toURI().toURL());
    remoteConfig.addURI(uri);
View Full Code Here

    String refName = Constants.R_TAGS + tagName;
    RefUpdate tagRef = repo.updateRef(refName);
    tagRef.setNewObjectId(tagId);
    tagRef.setForceUpdate(forceUpdate);
    tagRef.setRefLogMessage("tagged " + name, false); //$NON-NLS-1$
    Result updateResult = tagRef.update(revWalk);
    switch (updateResult) {
    case NEW:
    case FORCED:
      return repo.getRef(refName);
    case LOCK_FAILURE:
View Full Code Here

          throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, newHead));
        RefUpdate updateRef = db.updateRef(newRefName);
        updateRef.setNewObjectId(startAt);
        updateRef.setForceUpdate(createForce);
        updateRef.setRefLogMessage(MessageFormat.format(CLIText.get().branchCreatedFrom, startBranch), false);
        Result update = updateRef.update();
        if (update == Result.REJECTED)
          throw die(MessageFormat.format(CLIText.get().couldNotCreateBranch, newHead, update.toString()));
      } else {
        if (verbose)
          rw = new RevWalk(db);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.